3D geometry in JavaScript
Figure 1: the 3D space
Our vector is an object which extends standard Array object - derived as Point from javascript, see source.
- dist - distance between two vectors
- dot - dot product
- cross - cross product
- direction - angle components of 3D vector see Figure 1 above
- norm - normalize vector
- sub - subtract
- add - addition
- scale - product or divide by scalar
- mag - magnitude
- unit - unit vector (see norm)
Figure 2: the result of two skew segments distance represented by ab segment
- intsect - calculates shortest distance between two skew line segment in 3D space.
Note: line segments must not be parallel and not coplanar - they must be on the same plane.