Namespace LinaJS
Namespace for global constants and functions.
Defined in: lina.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Field Attributes | Field Name and Description |
---|---|
<static> <constant> |
LinaJS.DEG_TO_RAD
Factor that converts degree to radians (alias: D2R).
|
<static> <constant> |
LinaJS.EPS
Default epsilon value use in some comparisons.
|
<static> <constant> |
LinaJS.EPS_SQUARED
Squared LinaJS.EPS.
|
<static> <constant> |
LinaJS.RAD_TO_DEG
Factor that converts radians to degree (alias: R2D).
|
Method Attributes | Method Name and Description |
---|---|
<static> |
LinaJS.angleDiff(a1, a2)
Return angle from a1 to a2 normalized to [-Pi < a <= +Pi]
|
<static> |
LinaJS.clamp(f, min, max)
Return value clamped [min <= f <= max]
|
<static> |
LinaJS.compare(a, b, eps)
Return true, if lina.js objects a and b are the same (within eps).
|
<static> |
LinaJS.distancePtLine(pt, ptA, ptB)
Return shortest (vertical) distance between a point and a line through ptA/ptB.
|
<static> |
LinaJS.distancePtSegment(pt, ptA, ptB)
Return shortest distance between a point and the line segment from ptA to ptB.
|
<static> |
LinaJS.identity33()
Return a new Matrix3 (same as 'new Matrix3()').
|
<static> |
LinaJS.intersectMovingCircles(c1, c2, maxT)
Intersection of two moving circles.
|
<static> |
LinaJS.linesIntersect(pt1, pt2, pt3, pt4)
Return intersection point of line segment pt1/pt2 with with segment pt3/pt4.
|
<static> |
LinaJS.normAngle(a)
Return angle normalized to [0 <= a < 2*Pi]
|
<static> |
LinaJS.polarToPt(a, r)
Return a point {x:_, y:_} for the given polar coordinates.
|
<static> |
LinaJS.polarToVec(a, r)
Return a vector {dx:_, dy:_} for the given polar coordinates.
|
<static> |
LinaJS.random(min, max)
Return random float value f, with min <= f <= max').
|
<static> |
LinaJS.randomInt(min, max)
Return random integer value i, with min <= i <= max').
|
<static> |
LinaJS.reflectedVector(vec, reflectionNormal)
Reflect this vector (in-place) and return this instance.
|
<static> |
LinaJS.rotation33(a)
Return a new Matrix3 that represents a rotation about (0/0).
|
<static> |
LinaJS.scale33(fx, fy)
Return a new Matrix3 that represents a scaling about (0/0).
|
<static> |
LinaJS.segmentsIntersect(pt1, pt2, pt3, pt4)
Return intersection point of line segment pt1/pt2 with with segment pt3/pt4.
|
<static> |
LinaJS.translation33(dx, dy)
Return a new Matrix3 that represents a translation.
|
<static> |
LinaJS.vecToPolar(x, y)
Return polar coordinates {a:_, r:_} for a cartesian vector or point.
|
Field Detail
<static> <constant>
LinaJS.DEG_TO_RAD
Factor that converts degree to radians (alias: D2R).
<static> <constant>
LinaJS.EPS
Default epsilon value use in some comparisons.
<static> <constant>
LinaJS.EPS_SQUARED
Squared LinaJS.EPS.
<static> <constant>
LinaJS.RAD_TO_DEG
Factor that converts radians to degree (alias: R2D).
Method Detail
<static>
LinaJS.angleDiff(a1, a2)
Return angle from a1 to a2 normalized to [-Pi < a <= +Pi]
- Parameters:
- a1
- a2
<static>
LinaJS.clamp(f, min, max)
Return value clamped [min <= f <= max]
- Parameters:
- f
- min
- max
<static>
LinaJS.compare(a, b, eps)
Return true, if lina.js objects a and b are the same (within eps).
This function is not optimized for speed, but handy for unit tests.
- Parameters:
- a
- {float|Point2|Vec2|Matrix3,JS-Object,...}
- b
- must have the same type as a
- eps
- {float} Maximum accepted difference, defaults to 0.00001
<static>
LinaJS.distancePtLine(pt, ptA, ptB)
Return shortest (vertical) distance between a point and a line through ptA/ptB.
- Parameters:
- pt
- ptA
- ptB
<static>
LinaJS.distancePtSegment(pt, ptA, ptB)
Return shortest distance between a point and the line segment from ptA to ptB.
- Parameters:
- pt
- ptA
- ptB
<static>
LinaJS.identity33()
Return a new Matrix3 (same as 'new Matrix3()').
<static>
{ptColl|vColl|t}
LinaJS.intersectMovingCircles(c1, c2, maxT)
Intersection of two moving circles.
- Parameters:
- c1
- {x, y, vx, vy, r}
- c2
- {x, y, vx, vy, r}
- {float} maxT
- Returns:
- {ptColl|vColl|t} or null
<static>
{pt|null|undefined}
LinaJS.linesIntersect(pt1, pt2, pt3, pt4)
Return intersection point of line segment pt1/pt2 with with segment pt3/pt4.
- Parameters:
- pt1
- pt2
- pt3
- pt4
- Returns:
- {pt|null|undefined} intersection point {x:_, y:_} or null if there is no intersection. undefined is returned, if segments are collinear.
<static>
LinaJS.normAngle(a)
Return angle normalized to [0 <= a < 2*Pi]
- Parameters:
- a
<static>
LinaJS.polarToPt(a, r)
Return a point {x:_, y:_} for the given polar coordinates.
- Parameters:
- a
- r
<static>
LinaJS.polarToVec(a, r)
Return a vector {dx:_, dy:_} for the given polar coordinates.
- Parameters:
- a
- r
<static>
LinaJS.random(min, max)
Return random float value f, with min <= f <= max').
random(10); // return 0.00 .. 10.00 random(2, 5); // return 2.00 .. 5.00
- Parameters:
- min
- max
<static>
LinaJS.randomInt(min, max)
Return random integer value i, with min <= i <= max').
randomInt(10); // return 0..10 randomInt(2, 5); // return 2..5
- Parameters:
- min
- max
<static>
{Vec2}
LinaJS.reflectedVector(vec, reflectionNormal)
Reflect this vector (in-place) and return this instance.
- Parameters:
- {Vec2} vec
- {Vec2} reflectionNormal
- Normal vector pointing from reflection line towards vec.
- Returns:
- {Vec2}
<static>
LinaJS.rotation33(a)
Return a new Matrix3 that represents a rotation about (0/0).
- Parameters:
- a
<static>
LinaJS.scale33(fx, fy)
Return a new Matrix3 that represents a scaling about (0/0).
- Parameters:
- fx
- fy
<static>
LinaJS.segmentsIntersect(pt1, pt2, pt3, pt4)
Return intersection point of line segment pt1/pt2 with with segment pt3/pt4.
- Parameters:
- pt1
- pt2
- pt3
- pt4
<static>
LinaJS.translation33(dx, dy)
Return a new Matrix3 that represents a translation.
- Parameters:
- dx
- dy
<static>
LinaJS.vecToPolar(x, y)
Return polar coordinates {a:_, r:_} for a cartesian vector or point.
- Parameters:
- x
- y