Packagecom.fileitup.fisixengine.utils
Classpublic class Line

A utility class for various calculation involving line segments



Public Properties
 PropertyDefined by
  distance : Number
[read-only]Also, stores the length in 'lastDistance' This is useful when retrieving the distance of a static line and trying to avoid redundant sqrt() operations
Line
  lastDistance : Number = 0
Line
  lastNormal : Vector
Line
  vector : Vector
[read-only]
Line
  vectorA : Vector
Line
Public Methods
 MethodDefined by
  
Line(vA:Vector, vB:Vector)
Line
  
addVector(v:Vector):void
translates both vectors of the line by the given vector
Line
  
Calculates the right-hand normal of the vector
Line
  
pointOnLine(t:Number, limitToEnds:Boolean = true):Vector
Finds a point on the line from a given percentage
Line
  
render(g:Graphics):void
Draws a line between the two points of the line on the given Graphics object
Line
Property detail
distanceproperty
distance:Number  [read-only]

Also, stores the length in 'lastDistance' This is useful when retrieving the distance of a static line and trying to avoid redundant sqrt() operations

Implementation
    public function get distance():Number
lastDistanceproperty 
public var lastDistance:Number = 0
lastNormalproperty 
public var lastNormal:Vector
vectorproperty 
vector:Vector  [read-only]

Implementation
    public function get vector():Vector
vectorAproperty 
public var vectorA:Vector
Constructor detail
Line()constructor
public function Line(vA:Vector, vB:Vector)Parameters
vA:Vector
 
vB:Vector
Method detail
addVector()method
public function addVector(v:Vector):void

translates both vectors of the line by the given vector

Parameters
v:Vector
getNormal()method 
public function getNormal():Vector

Calculates the right-hand normal of the vector

Returns
Vector
pointOnLine()method 
public function pointOnLine(t:Number, limitToEnds:Boolean = true):Vector

Finds a point on the line from a given percentage

Parameters
t:Number — the percentage on the line (usually between 0-1) where 0 returns the position of vectorA and 1 returns the position of vetorB
 
limitToEnds:Boolean (default = true) — if true, the t value is clipped between 0 and 1

Returns
Vector — A vector containing the x,y position of a point on a line
render()method 
public function render(g:Graphics):void

Draws a line between the two points of the line on the given Graphics object

Parameters
g:Graphics