Search:
Class Line
class
Line
The Line class defines a new object type for a line. It is in a sense a "point-slope" definition of a line.
A Line has a base point and a direction, the direction being a unit vector.
This is an effective way of defining a line in a way that does not limit it to any specific segment and allows for Affine Transformations to be applied.
Defined in
Line.js
Variable Summary
The "anchor" point.
The direction of the line; will be a unit vector.
Constructor Summary
Function Summary
Tests to see if a point lies on the line.
Gets the distance between a line and another line, plane, or a point.
Finds the UNIQUE intersection of a line and another Line or Plane.
Tests if this line intersects with a given line or plane.
Tests to see if a line is parallel to another line or plane.
Returns the point on the line at a given value of t.
Finds the point on this line closest to a given line or point.
Returns the line's reflection in the given point, line, or plane.
Returns a string representation of the Line.
Variable Details
variable mathnetics.point3D base
The "anchor" point.
variable mathnetics.point3D direction
The direction of the line; will be a unit vector. Use mathnetics.point3D object for this to allow Affine Transformations.
variable public static Line x
The x-axis. Base: (0,0,0), Direction: Vector.i
variable public static Line y
The y-axis. Base: (0,0,0), Direction: Vector.j
variable public static Line z
The z-axis. Base: (0,0,0), Direction: Vector.k
Constructor Details
constructor Line
Line(Line
line)
The constructor function for a new Line. If only a Line object is supplied as a parameter, a duplicate of that Line will be created.
Parameters:
standard
base
- the base point of the Line; can be a mathnetics.point2D, mathnetics.point3D or Vector (of dimension 2 or 3) object. The actual base point of the Line will be a point3D object.
direction
the direction of the Line; can be a mathnetics.point2D, mathnetics.point3D or Vector. Actual direction will be a normalized point3D object. clone
line
- the line to clone as a new one Function Details
function contains
public
boolean
contains(mathnetics.point3D
point)
Tests to see if a point lies on the line.
Parameters:
point
- the point to test
Returns:
true iff point is on line, false otherwise
function distanceFrom
public
Number
distanceFrom(Line
line)
public
Number
distanceFrom(Plane
plane)
public
Number
distanceFrom(mathnetics.point3D
point)
Gets the distance between a line and another line, plane, or a point.
Parameters:
Line
line
Plane
plane
- not implemented yet! Point
point
- can also be a mathnetics.point2D
Returns:
the distance between object and the line; 0 if two lines have same base or one contains the base of the other
function equalTo
public
boolean
equalTo(Line
line)
Tests two lines for equality. Will return true if line is parallel or antiparallel.
Parameters:
line
- the line to compare
Returns:
true if line has same base point and is parallel or antiparallel
function intersection
public
mathnetics.point3D
intersection(Plane
plane)
public
mathnetics.point3D
intersection(Line
line)
Finds the UNIQUE intersection of a line and another Line or Plane.
Parameters:
Plane
plane
- not implemented yet! Line
line
Returns:
the intersection point (null if obj does not intersect with line)
function intersects
public
boolean
intersects(Plane
plane)
public
boolean
intersects(Line
line)
Tests if this line intersects with a given line or plane.
Parameters:
Plane
plane
Line
line
- to test for intersection with the line
Returns:
true if there is a unique intersection point between the line and the given line or plane, false otherwise
function isParallel
public
boolean
isParallel(Line
line)
public
boolean
isParallel(Plane
plane)
Tests to see if a line is parallel to another line or plane.
Parameters:
Line
line
- Line with which to test parallelity Plane
plane
- a Plane, with which to test parallelity
Returns:
true if parallel or anti-parallel, false otherwise
function liesIn
public
boolean
liesIn(Plane
plane)
Tests if a Line lies in a given Plane.
Parameters:
plane
- the plane which may or may not contain this Line
Returns:
true iff Line lies in plane, false otherwise
function pointAt
public
mathnetics.point3D
pointAt(Number
t)
Returns the point on the line at a given value of t.
Parameters:
t
- the time value at which to find the point on the line
Returns:
this.base + t*this.direction
function pointClosestTo
public
mathnetics.point3D
pointClosestTo(Line
line)
public
mathnetics.point3D
pointClosestTo(Vector
point)
Finds the point on this line closest to a given line or point.
Parameters:
Line
line
- the line from which to find the closest point on this line Point
point
- a mathnetics.point2D/3D (or Vector)
Returns:
the point on the original line closes to obj
function reflectionIn
public
Line
reflectionIn(mathnetics.point3D
point)
Returns the line's reflection in the given point, line, or plane.
Parameters:
Plane
plane
- the plane in which to reflect Line
line
point
point
- can also be a point2D or Vector
Returns:
a new line, the old one reflected in obj
function rotate
Rotates a line through an angle about an arbitrary line. Be careful, rotation axis' direction affects the outcome!
Parameters:
deg
- the degrees, in radians, to rotate the line
line
- the line about which to rotate this line
Returns:
a new line that is the old one rotated
function toString
public
String
toString()
Returns a string representation of the Line.
Returns:
the string representation of the line, containing all relevant info
function translate
public
Line
translate(Number
dx, Number
dy, Number
dz)
Returns a new Line that is the old one translated by dx, dy, and dz. Note that direction does not change in a translation, only the base point.
Parameters:
dx
- the x translation
dy
- the y translation
dz
- the z translation
Returns:
a new Line, the old one translated