xyz

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package xyz contains operations in 3d coordinate space. Each layout must have 3 ordinates (and thus each coordinate) it is assumed that x,y,z are ordinates with indexes 0,1,2 respectively

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distance

func Distance(point1, point2 geom.Coord) float64

Distance calculates the distance between the two coordinates in 3d space.

Example
p1 := geom.Coord{0, 0, 0}
p2 := geom.Coord{10, 0, 0}

distance := xyz.Distance(p1, p2)

fmt.Println(distance)
Output:

10

func DistanceLineToLine

func DistanceLineToLine(line1Start, line1End, line2Start, line2End geom.Coord) float64

DistanceLineToLine computes the distance between two 3D segments

Example
line1Start := geom.Coord{10, 0, 10}
line1End := geom.Coord{10, 0, -10}
line2Start := geom.Coord{0, 0, 10}
line2End := geom.Coord{0, 0, -10}

distance := xyz.DistanceLineToLine(line1Start, line1End, line2Start, line2End)

fmt.Println(distance)
Output:

10

func DistancePointToLine

func DistancePointToLine(point, lineStart, lineEnd geom.Coord) float64

DistancePointToLine calculates the distance from point to a point on the line

Example
p1 := geom.Coord{0, 0, 0}
lineStart := geom.Coord{10, 0, 10}
lineEnd := geom.Coord{10, 0, -10}

distance := xyz.DistancePointToLine(p1, lineStart, lineEnd)

fmt.Println(distance)
Output:

10

func Equals

func Equals(point1, other geom.Coord) bool

Equals determines if the two coordinates have equal in 3d space

Example
p1 := geom.Coord{0, 0}
p2 := geom.Coord{10, 0}

distance := xyz.Equals(p1, p2)

fmt.Println(distance)
Output:

false

func VectorDot

func VectorDot(v1Start, v1End, v2Start, v2End geom.Coord) float64

VectorDot calculates the dot product of two vectors

Example
v1 := geom.Coord{0.44022007739138613, 0.833525569726002, 0.49302724302422873}
v2 := geom.Coord{0.05162589254031058, 0.977176382882891, 0.8789402270478548}
v3 := geom.Coord{0.7534455876162328, 0.6173555367190986, 0.27126435983727104}
v4 := geom.Coord{0.8452219342333697, 0.5825792503932398, 0.4764854482064663}
dot := xyz.VectorDot(v1, v2, v3, v4)

fmt.Println(dot)
Output:

0.038538086185549936

func VectorLength

func VectorLength(vector geom.Coord) float64

VectorLength calculates the length of the vector from 0,0,0 to vector

Example
v1 := geom.Coord{0.050809870984833916, 0.31035561291492797, 0.001499306503938036}
length := xyz.VectorLength(v1)

fmt.Println(length)
Output:

0.3144908542029304

func VectorNormalize

func VectorNormalize(vector geom.Coord) geom.Coord

VectorNormalize creates a coordinate that is the normalized vector from 0,0,0 to vector

Example
v1 := geom.Coord{0.9807055460429551, 0.8643056316322373, 0.08720913878428183}
normalized := xyz.VectorNormalize(v1)

fmt.Println(normalized)
Output:

[0.7485619198694545 0.6597151260937918 0.06656579094706616]

Types

This section is empty.

Jump to

Keyboard shortcuts

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