new Arrow(trajectoryHelper)
Represents one Arrow with: position, time lived, time till death, length, forward speed, width
Parameters:
Name | Type | Description |
---|---|---|
trajectoryHelper |
TrajectoryHelper | TrajectoryHelper to be used for this arrow |
Members
(readonly) position :list
List of positions over time
Type:
- list
(readonly) timeBorn :int
Timestep when this arrow was born
Type:
- int
(readonly) timeData :list
List of head/tail positions and length over time
Type:
- list
(readonly) timeDeath :int
Timestep when this arrow dies
Type:
- int
(readonly) width :number
Width of this arrow
Type:
- number
Methods
(private) _distancePointLine(point, lineStart, lineEnd) → {number}
Returns the distance from a point to a line segment
Parameters:
Name | Type | Description |
---|---|---|
point |
Point | Point |
lineStart |
Point | Start point of line |
lineEnd |
Point | End point of line |
Returns:
distance
- Type
- number
calcDataValues(time)
Calculates the length, and head and tail of this arrow
this.position has to be set
Parameters:
Name | Type | Description |
---|---|---|
time |
int | The time to calculate this values for |
distance(other, time, dist) → {boolean}
Returns true if distance is kept.
Parameters:
Name | Type | Description |
---|---|---|
other |
Arrow | The arrow to calculate the distance to |
time |
int | time for calculation |
dist |
float | the dist to check for |
Returns:
true if distance is greater than dist
- Type
- boolean
distanceToMultiple(others, time, dist) → {boolean}
Returns true if distance to all is kept
Parameters:
Name | Type | Description |
---|---|---|
others |
Arrow | The arrows to calculate the distance to |
time |
int | time for calculation |
dist |
float | the dist to check for |
Returns:
true if distance is greater than dist
- Type
- boolean
draw(ctx, time, scale)
Draws the arrow on a canvas
Parameters:
Name | Type | Description |
---|---|---|
ctx |
Context2D | Context for drawing |
time |
number | Timestep for drawing (including fraction times) |
scale |
number | scales the whole arrow by scale |
getPolygon(time, borderopt) → {SAT.Polygon}
Returns a polygon that is defined by the linesegment
from tail -> position -> head with the width of this.width
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
time |
int | time for calculation | |
border |
float |
<optional> |
border to add around polygon, default 0 |
Returns:
Polygon approximation
- Type
- SAT.Polygon
isAlive(time) → {boolean}
returns wether this arrow is alive at the given time
Parameters:
Name | Type | Description |
---|---|---|
time |
int | asked for timestep |
Returns:
true if arrow is alive at given position
- Type
- boolean
propagateToTime(startTime, time)
adds a position for the arrow at "time" timestep,
based on the position of startTime and calculates the Data values
for this timestep
Parameters:
Name | Type | Description |
---|---|---|
startTime |
int | known timestep |
time |
int | asked for timestep |