eurocat2k / 3dgeometry

3d geometry in JS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

3D geometry

3D geometry in JavaScript

Vector

3D coordinate space

Figure 1: the 3D space

Our vector is an object which extends standard Array object - derived as Point from javascript, see source.

Static methods

  • 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)

Segment

Segments shortest distance in 3D space

Figure 2: the result of two skew segments distance represented by ab segment

Static method

  • 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.

About

3d geometry in JS

License:MIT License


Languages

Language:JavaScript 84.4%Language:HTML 10.9%Language:MATLAB 4.7%