vect3d

package module
v0.0.0-...-75a5e34 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: Apache-2.0 Imports: 3 Imported by: 2

README

#vect3d#

Package csvrec implements several 3d vector functions.

Documentation

Overview

Package vect3d implements several 3d vector functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(a, b [3]float64) (result [3]float64)

Add returns the 3d vector a + b

func CrossProduct

func CrossProduct(a, b [3]float64) (result [3]float64)

CrossProduct returns the crossproduct of a and b a and b are 3d vectors

func DistPt2Line

func DistPt2Line(a, n, b [3]float64) float64

DistPt2Line returns the shortest distance from b to the line defined by a and n a is a point on the line n is the vector of the line b is a point not on the line The result is the shortest distance from b to the line

func DistPt2Pt

func DistPt2Pt(a, b [3]float64) float64

DistPt2Pt returns the distance from 3d point a to 3d point b a is a point b is another point The result is the shortest distance from b to the line

func DotProduct

func DotProduct(veca, vecb [3]float64) float64

DotProduct returns the dot product of 3d vectors a and b.

func GetAngle

func GetAngle(a, b [3]float64) float64

GetAngle returns cos(theta) where theta is the angle between 3d vectors a and b.

func GetComplexRotationMatrix

func GetComplexRotationMatrix(xAngle, yAngle, zAngle float64) (Q [][]float64)

GetComplexRotationMatrix returns a compound rotation matrix for rotating about the x, y, and z axis respectively.

func GetRotationMatrix

func GetRotationMatrix(axis [3]float64, angle float64) (Q [][]float64)

GetRotationMatrix returns the Q matrix needed for RotateTransPt

func GetSignedAngle

func GetSignedAngle(a, b, axis [3]float64) float64

GetSignedAngle returns the signed angle theta (radians) between 3d vectors a and b about the given the axis.

func Magnitude

func Magnitude(vec [3]float64) float64

Magnitude returns the magnitude of a 3d vector.

func Make2D

func Make2D(r, c int) (A [][]float64)

Make2D creates a slice of dimension [r][c]. In terms of a matrix, this is analogous to an r row by c column matrix.

func Make3D

func Make3D(r, c, d int) (A [][][]float64)

Make3D creates a slice of dimension [r][c][d]. In terms of a matrix, this is analogous to an r row by c column by d depth matrix.

func NearestPtOnLine

func NearestPtOnLine(a, n, b [3]float64) [3]float64

NearestPtOnLine returns the point on a line defined by point a and normalized vector n that is closest to b a is a point on the line n is the NORMALIZED vector of the line b is a point not necessarily on the line

func Normalize

func Normalize(a [3]float64) [3]float64

Normalize returns a/|a| where a is a 3d vector

func ReflectX

func ReflectX(a [3]float64) (b [3]float64)

ReflectX moves a point to its mirrored location about the X plane a is the point to be moved b is the moved point

func ReflectY

func ReflectY(a [3]float64) (b [3]float64)

ReflectY moves a point to its mirrored location about the X plane a is the point to be moved b is the moved point

func ReflectZ

func ReflectZ(a [3]float64) (b [3]float64)

ReflectZ moves a point to its mirrored location about the X plane a is the point to be moved b is the moved point

func Rotate3D

func Rotate3D(A [3][3]float64, b [3]float64) (c [3]float64)

Rotate3D rotates vector b by rotation matrix A. This is matrix multiplication of size 3x3 X 3x1 = 3x1.

func RotateAxis

func RotateAxis(a, origin, axis [3]float64, angle float64) (b [3]float64)

RotateAxis rotates a point a about an origin and an axis a specified angle (radians) a is the point to be moved b is the moved point It doesn't require the axis to be normalized.

func RotateN1N2

func RotateN1N2(a, origin, n1, n2 [3]float64, angle float64) (b [3]float64)

RotateN1N2 rotates a point a about an origin and an axis, formed by n2-n1, a specified angle (radians) a is the point to be moved b is the moved point

func RotateN1N2N3

func RotateN1N2N3(a, origin, n1, n2, n3 [3]float64, angle float64) (b [3]float64, err error)

RotateN1N2N3 rotates a point around an origin in the plane specified by three points in the plane (n1, n2, and n3) a is the point to be moved b is the moved point

func RotateTransPt

func RotateTransPt(a, origin, trans [3]float64, Q [][]float64) (b [3]float64)

RotateTransPt rotates a point given a rotation matrix Q, and an origin and translates it by trans

func RotateX

func RotateX(a, origin [3]float64, angle float64) (b [3]float64)

RotateX rotates point a about the given origin and X axis a specified angle (radians) a is the point to be moved b is the moved point

func RotateY

func RotateY(a, origin [3]float64, angle float64) (b [3]float64)

RotateY rotates point a about the given origin and Y axis a specified angle (radians) a is the point to be moved b is the moved point

func RotateZ

func RotateZ(a, origin [3]float64, angle float64) (b [3]float64)

RotateZ rotates point a about the given origin and Z axis a specified angle (radians) a is the point to be moved b is the moved point

func ScalerMult

func ScalerMult(a [3]float64, b float64) (result [3]float64)

ScalerMult returns a * b a is three dimensional vector b is a scalar

func Subtract

func Subtract(a, b [3]float64) (result [3]float64)

Subtract returns the 3d vector a - b

func Translate

func Translate(a, dir [3]float64) (b [3]float64)

Translate moves a 3d point a along the vector dir to 3d point b a is the point to be moved b is the moved point dir is a vector representing the direction and distance a is moved.

func TranslateDist

func TranslateDist(a, dir [3]float64, dist float64) (b [3]float64)

TranslateDist moves a 3d point a along the vector dir a distance d to 3d point b a is the point to be moved b is the moved point dir is a vector representing the direction and distance a is moved.

func Transpose2dFloat

func Transpose2dFloat(A [][]float64) (B [][]float64, err error)

Transpose2dFloat creates the transpose of a rectangular 2-dimensional slice of type float64 as if it were a transposable matrix.

func TriNormal

func TriNormal(n1, n2, n3 [3]float64) [3]float64

TriNormal returns the normal of a triangle with a normal that is the cross product of n2 - n1 and n3 - n2

func YawPitchRoll

func YawPitchRoll(yaw, pitch, roll float64, pt [3]float64) (rotpt [3]float64)

YawPitchRoll rotates a point through yaw, pitch, and roll, in that order according to the Tait-Bryan z-y'-x” intrinsic rotation convention. yaw, pitch, and roll are entered in degrees with bounds: -360 < yaw < 360; -360 < pitch < 360; -360 < roll < 360. pt is the point to be rotated. rotpt is the rotated point.

Types

This section is empty.

Jump to

Keyboard shortcuts

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