arithm

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2021 License: BSD-3-Clause Imports: 5 Imported by: 6

README

Arithmetic Functions

Affine transforms, a solver for linear equations, paths…

Documentation

Overview

Package arithm implements points, affine transformations, arithmetic for polynomials, and a linear equations solver.

BSD License

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of this software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

This section is empty.

Variables

View Source
var Deg2Rad float64 = 0.01745329251

Deg2Rad is a constant for converting from DEG to RAD or vice versa

View Source
var Epsilon float64 = 0.0000001

Epsilon : numbers below ε are considered 0

View Source
var Origin = P(float64(0), float64(0))

Origin represents the frequently used constant (0,0).

Functions

func Is0

func Is0(n float64) bool

Is0 is a predicate: is n = 0 ?

func Is1

func Is1(n float64) bool

Is1 is a predicate: is n = 1.0 ?

func Round

func Round(n float64) float64

Round to ε.

func T

func T() tracing.Trace

T traces to the equations-tracer.

func Zap

func Zap(n float64) float64

Zap makes n = 0 if n "means" to be zero

Types

type AT

type AT []float64 // a 3x3 matrix, flattened by rows

AT is an affine transform, a matrix type used for transforming vectors.

func Identity

func Identity() AT

Identity transform. Will transform a point onto itself.

func Rotation

func Rotation(theta float64) AT

Rotation transform. Rotate a point counter-clockwise around the origin. Argument is in radians.

func Translation

func Translation(p Pair) AT

Translation transform. Translate a point by (dx,dy).

func (AT) Combine

func (m AT) Combine(n AT) AT

Combine 2 affine transformation to a new one. Returns a new transformation without changing the argument(s).

func (AT) String

func (m AT) String() string

Debug Stringer for an affine transform.

func (AT) Transform

func (m AT) Transform(p Pair) Pair

Transform a 2D-point. The argument is unchanged and a new pair is returned.

type Pair

type Pair complex128

Pair is an interface for pairs / 2D-points

func C2P

func C2P(c complex128) Pair

C2P returns a Pair from a complex number.

func P

func P(x, y float64) Pair

P is a quick notation for contructing a pair from floats.

func (Pair) C

func (p Pair) C() complex128

C returns a Pair as a complex number.

func (Pair) Equal

func (p Pair) Equal(p2 Pair) bool

Equal compares two pairs.

func (Pair) F

func (p Pair) F() (float64, float64)

F is a quick notation for getting float values from a pair.

func (Pair) IsOrigin

func (p Pair) IsOrigin() bool

IsOrigin is a predicate: is this pair origin?

func (Pair) Rotated

func (p Pair) Rotated(theta float64) Pair

Rotated returns a new pair rotated around origin by theta (counterclockwise).

func (Pair) Rotatedaround

func (p Pair) Rotatedaround(v Pair, theta float64) Pair

Rotatedaround returns a new pair rotated around v by theta (counterclockwise).

func (Pair) Scaled

func (p Pair) Scaled(a float64) Pair

Scaled returns a new pair scaled by factor a.

func (Pair) Shifted

func (p Pair) Shifted(v Pair) Pair

Shifted returns a new pair translated by v.

func (Pair) String

func (p Pair) String() string

Pretty Stringer for simple pairs.

func (Pair) X

func (p Pair) X() float64

X is the x-part of a pair.

func (Pair) XScaled

func (p Pair) XScaled(a float64) Pair

XScaled returns a new pair x-scaled by factor a.

func (Pair) Y

func (p Pair) Y() float64

Y is the y-part of a pair.

func (Pair) YScaled

func (p Pair) YScaled(a float64) Pair

YScaled returns a new pair y-scaled by factor a.

func (Pair) Zap

func (p Pair) Zap() Pair

Zap rounds x-part and y-part to Epsilon.

Directories

Path Synopsis
Package jhobby deals with MetaFont/MetaPost-like paths.
Package jhobby deals with MetaFont/MetaPost-like paths.
Package polygon deals with polygons, ie paths with straight lines.
Package polygon deals with polygons, ie paths with straight lines.
Package polyn is for arithmetic with linear polynomials and linear equations.
Package polyn is for arithmetic with linear polynomials and linear equations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL