d3

package
v0.0.0-...-9c88ebf Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: BSD-3-Clause Imports: 6 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Prec = 4

Prec is the precision for the String method on F

Functions

func MinMax

func MinMax(pts ...Pt) (Pt, Pt)

MinMax takes any number of points and returns a min point with the lowest X and the lowest Y in the entire set and a max point with the highest X and highest Y in the set.

Types

type D3

type D3 struct {
	X, Y, Z float64
}

D3 is an abstract two dimensional struct holding the methods shared by both Pt and V.

func (D3) Mag

func (d D3) Mag() float64

Mag returns the magnitude of the D3.

func (D3) Mag2

func (d D3) Mag2() float64

Mag2 returns the sqaure of the magnitude of the D3.

func (D3) Pt

func (d D3) Pt() Pt

Pt converts D2 to a Pt.

func (D3) String

func (d D3) String() string

String fulfills Stringer representing the D3 as a String.

func (D3) V

func (d D3) V() V

Pt converts D2 to a V.

type Point

type Point interface {
	Pt() Pt
}

Point can return an instance of Pt.

type Pt

type Pt D3

Pt represets a three dimensional point.

func Max

func Max(pts ...Pt) Pt

Max returns a Pt with the highest X, highest Y and highest Z.

func Min

func Min(pts ...Pt) Pt

Min returns a Pt with the lowest X, lowest Z and the lowest Y.

func (Pt) Add

func (pt Pt) Add(v V) Pt

Add a V to a Pt

func (Pt) AssertEqual

func (pt Pt) AssertEqual(actual interface{}, t cmpr.Tolerance) error

AssertEqual fulfils geomtest.AssertEqualizer

func (Pt) Distance

func (pt Pt) Distance(pt2 Pt) float64

Distance returns the distance between to points

func (Pt) Mag

func (pt Pt) Mag() float64

Mag returns the magnitude of the point relative to the origin

func (Pt) Mag2

func (pt Pt) Mag2() float64

Mag2 returns the square of the magnitude. For comparisions this can be more efficient as it avoids a sqrt call.

func (Pt) Multiply

func (pt Pt) Multiply(scale float64) Pt

Multiply performs a scalar multiplication on the Pt

func (Pt) Pt

func (pt Pt) Pt() Pt

Pt is defined on Pt to fulfill Point.

func (Pt) Round

func (pt Pt) Round() Pt

Round a Pt to it's nearest integer values.

func (Pt) String

func (pt Pt) String() string

String fulfills Stringer, returns the vector as "(X, Y)"

func (Pt) Subtract

func (pt Pt) Subtract(pt2 Pt) V

Subtract returns the difference between two points as V

type Pt1

type Pt1 interface {
	Pt1(t0 float64) Pt
}

Pt1 is a one dimensional parametric curve.

type Pt2

type Pt2 interface {
	Pt2(t0, t1 float64) Pt
}

Pt2 is a two dimensional parametric surface.

type Pt2c1

type Pt2c1 interface {
	Pt2(t0 float64) Pt1
}

Pt2c1 is a two dimensional parametric surface that returns a curve on the surface.

type Q

type Q struct {
	A, B, C, D float64
}

Q is a quaternion used for rotations. B, C and D correspond to the X, Y and Z axis.

func QV

func QV(v V) Q

QV produces an instance of Q such that Q applied to V{1,0,0} will point in the same direction as the argument v.

func QX

func QX(ang angle.Rad) Q

QX returns Q rotated around the X axis.

func QY

func QY(ang angle.Rad) Q

QY returns Q rotated around the Y axis.

func QZ

func QZ(ang angle.Rad) Q

QY returns Q rotated around the Z axis.

func (Q) Normalize

func (q Q) Normalize() Q

Normalize returns an instance of Q pointint in the same direction with a magnitude of 1.

func (Q) Product

func (q Q) Product(q2 Q) Q

Product applies the rotation of q2 to q.

func (Q) String

func (q Q) String() string

String fullfils Stringer.

func (Q) T

func (q Q) T() *T

T produces to transform equal to Q.

func (Q) TInv

func (q Q) TInv() *T

TInv fulfills TGenInv.

type Rotation

type Rotation struct {
	Angle angle.Rad
	Plane RotationPlane
}

Rotation fulfill TGen

func (Rotation) Pair

func (r Rotation) Pair() [2]*T

Pair fulfills GetTPair.

func (Rotation) T

func (r Rotation) T() *T

T fullfils TGen and produces a rotation of the given angle in the plane.

func (Rotation) TInv

func (r Rotation) TInv() *T

TInv fulfills TGenPair.

type RotationPlane

type RotationPlane byte

RotationPlane represents the planes for rotation.

const (
	XY RotationPlane = iota
	XZ
	YZ
)

The 3 planes for rotation

type Scale

type Scale V

Scale fulfills TGen and produces a T that scales by V.

func ScaleF

func ScaleF(f float64) Scale

ScaleF returns Scale with all dimensions equal to f.

func (Scale) Pair

func (s Scale) Pair() [2]*T

Pair fulfills TGenPair returning the Scale transform represented by V and it's inverse.

func (Scale) T

func (s Scale) T() *T

T fulfills TGen.

func (Scale) TInv

func (s Scale) TInv() *T

TInv fulfills TGenInv.

type T

type T [4][4]float64

T is a 3D transform.

func GetTInv

func GetTInv(t TGen) *T

GetTInv of a TGen will call TInv if available.

func GetTPair

func GetTPair(t TGen) [2]*T

GetTPair of a TGen will call Pair if available.

func Identity

func Identity() *T

Identity returns a copy of the identity transform.

func TProd

func TProd(ts ...*T) *T

TProd returns the product of multiple transforms.

func (*T) AssertEqual

func (t *T) AssertEqual(to interface{}, tol cmpr.Tolerance) error

AssertEqual fulfils geomtest.AssertEqualizer

func (*T) Inversion

func (t *T) Inversion() (*T, bool)

Inversion returns the inverse of T and a bool indicating if the inversion is valid.

func (*T) Pt

func (t *T) Pt(pt Pt) Pt

Pt applies T to pt.

func (*T) PtF

func (t *T) PtF(pt Pt) (Pt, float64)

PtF applies T to pt and also returns the scalar.

func (*T) PtScl

func (t *T) PtScl(pt Pt) Pt

PtScl applies T the pt and divides the result by the scalar.

func (*T) Pts

func (t *T) Pts(pts []Pt) []Pt

Pts applies T to pts.

func (*T) PtsScl

func (t *T) PtsScl(pts []Pt) []Pt

PtsScl applies to the pts and divides the results by the scalar.

func (T) String

func (t T) String() string

String fulfills Stringer.

func (*T) T

func (t *T) T(t2 *T) *T

T applies t2 to t.

func (*T) TInv

func (t *T) TInv() *T

TInv fulfills TGenInv. Some transforms do not have an inversion and in those cases the returned inverse will not be accurate.

func (*T) V

func (t *T) V(v V) V

Pts applies T to v.

func (*T) VF

func (t *T) VF(v V) (V, float64)

VF applies T to v and returns the result and the scalar.

type TGen

type TGen interface {
	T() *T
}

TGen represents a type that can generate a Transform.

type TGenInv

type TGenInv interface {
	TGen
	TInv() *T
}

TGenInv represents a type that can generate the inverse of a Transform.

type TGenPair

type TGenPair interface {
	TGen
	Pair() [2]*T
}

TGenPair provides a way to get both the Transform and it's Inverse at the same time which can sometimes be more efficient.

type TransformSet

type TransformSet struct {
	Head, Middle, Tail []*T
}

TransformSet builds up a chain of transformaitions.

func NewTSet

func NewTSet() *TransformSet

NewTSet creates a TransformSet.

func (*TransformSet) Add

func (ts *TransformSet) Add(t *T) *TransformSet

Add t to the middle

func (*TransformSet) AddBoth

func (ts *TransformSet) AddBoth(t [2]*T) *TransformSet

AddBoth appends the transform and it's inverse to the head and tail.

func (*TransformSet) Get

func (ts *TransformSet) Get() *T

Get produces a transform produces a transform by applying the transforms in head, then middle then applying tail in reverse.

type Translate

type Translate V

Translate fulfills TGen that translates by V

func (Translate) Pair

func (t Translate) Pair() [2]*T

Pair fulfills TGenPair returning the translate transform represented by V and it's inverse.

func (Translate) T

func (t Translate) T() *T

T fulfills TGen.

func (Translate) TInv

func (t Translate) TInv() *T

TInv fulfills TGenInv

type V

type V D3

V is a 3D vector.

func (V) Abs

func (v V) Abs() V

Abs returns a vector where all components are positive.

func (V) Add

func (v V) Add(v2 V) V

Add two vectors.

func (V) Ang

func (v V) Ang(v2 V) angle.Rad

Ang returns the angle between two vectors

func (V) AssertEqual

func (v V) AssertEqual(actual interface{}, t cmpr.Tolerance) error

AssertEqual fulfils geomtest.AssertEqualizer

func (V) Cross

func (v V) Cross(v2 V) V

Cross returns the cross product of the two vectors

func (V) Dot

func (v V) Dot(v2 V) float64

Dot returns the dot product of two vectors

func (V) Mag

func (v V) Mag() float64

Mag returns the magnitude (distance to origin) of the vector

func (V) Mag2

func (v V) Mag2() float64

Mag2 Returns the sqaure of the magnitude of the vector.

func (V) Multiply

func (v V) Multiply(scale float64) V

Multiply a vector by a scale.

func (V) Normal

func (v V) Normal() V

Normal returns a vector that has the same orientation but has a length of 1.

func (V) Project

func (v V) Project(v2 V) V

Project v2 onto v.

func (V) String

func (v V) String() string

String fulfills Stringer, returns the vector as "(X, Y)"

func (V) Subtract

func (v V) Subtract(v2 V) V

Subtract is the difference between two vectors.

func (V) V

func (v V) V() V

V is here to fulfill Vector interface.

type V1

type V1 interface {
	V1(t0 float64) V
}

V1 is a one dimensional parametric curve.

type Vector

type Vector interface {
	V() V
}

Vector can return an instance of V

Directories

Path Synopsis
Package affine allows for combinations of points where the sum of the coefficients is zero.
Package affine allows for combinations of points where the sum of the coefficients is zero.
curve
render
shape
box
Package box provids a 3D bounding box.
Package box provids a 3D bounding box.
cc

Jump to

Keyboard shortcuts

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