Constructor
new Arc(pc, r, startAngle, endAngle, counterClockwise)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pc |
Point
|
arc center |
r |
number
|
arc radius |
startAngle |
number
|
start angle in radians from 0 to 2*PI |
endAngle |
number
|
end angle in radians from 0 to 2*PI |
counterClockwise |
boolean
|
arc direction, true - clockwise, false - counter clockwise |
Members
sweep
Get sweep angle in radians. Sweep angle is non-negative number from 0 to 2*PI
- Source:
Methods
breakToFunctional() → {Array.<Arcs>}
Breaks arc in extreme point 0, pi/2, pi, 3*pi/2 and returns array of sub-arcs
- Source:
Returns:
- Type:
-
Array.<Arcs>
chordHeight() → {number}
Returns chord height ("sagitta") of the arc
- Source:
Returns:
- Type:
-
number
contains(pt) → {boolean}
Returns true if arc contains point, false otherwise
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pt |
Point
|
point to test |
Returns:
- Type:
-
boolean
distanceTo(shape) → {number|Segment}
Calculate distance and shortest segment from arc to shape and return array [distance, shortest segment]
- Source:
Parameters:
Name | Type | Description |
---|---|---|
shape |
Shape
|
Shape of the one of supported types Point, Line, Circle, Segment, Arc, Polygon or Planar Set |
Returns:
-
- Type:
-
number
distance from arc to shape -
- Type:
-
Segment
shortest segment between arc and shape (started at arc, ended at shape)
intersect(shape) → {Array.<Points>}
Returns array of intersection points between arc and other shape
- Source:
Parameters:
Name | Type | Description |
---|---|---|
shape |
Shape
|
Shape of the one of supported types |
Returns:
- Type:
-
Array.<Points>
reverse() → {Arc}
Returns new arc with swapped start and end angles and reversed direction
- Source:
Returns:
- Type:
-
Arc
rotate(angle, center) → {Arc}
Return new segment rotated by given angle around given point
If point omitted, rotate around origin (0,0)
Positive value of angle defines rotation counter clockwise, negative - clockwise
- Source:
Parameters:
Name | Type | Default | Description |
---|---|---|---|
angle |
number
|
0 | rotation angle in radians |
center |
Point
|
center point, default is (0,0) |
Returns:
- Type:
-
Arc
split(pt) → {Array.<Arc>}
When given point belongs to arc, return array of two arcs split by this point. If points is incident
to start or end point of the arc, return clone of the arc. If point does not belong to the arcs, return
empty array.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pt |
Point
|
Query point |
Returns:
- Type:
-
Array.<Arc>
svg(attrs) → {string}
Return string to draw arc in svg
- Source:
Parameters:
Name | Type | Description |
---|---|---|
attrs |
Object
|
an object with attributes of svg path element,
like "stroke", "strokeWidth", "fill" Defaults are stroke:"black", strokeWidth:"1", fill:"none" |
Returns:
- Type:
-
string
tangentInEnd() → {Vector}
Return tangent unit vector in the end point in the direction from end to start
- Source:
Returns:
- Type:
-
Vector
tangentInStart() → {Vector}
Return tangent unit vector in the start point in the direction from start to end
- Source:
Returns:
- Type:
-
Vector
toJSON() → {Object}
This method returns an object that defines how data will be
serialized when called JSON.stringify() method
- Source:
Returns:
- Type:
-
Object
transform(matrix) → {Arc}
Return new arc transformed using affine transformation matrix
Note, that non-equal scaling by x and y (matrix[0] != matrix[3]) produce illegal result TODO: support non-equal scaling arc to ellipse or throw exception ?
Note, that non-equal scaling by x and y (matrix[0] != matrix[3]) produce illegal result TODO: support non-equal scaling arc to ellipse or throw exception ?
- Source:
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix
|
affine transformation matrix |
Returns:
- Type:
-
Arc