Methods
Own
(static) GrahamScan(points) → {Array}
Calculate the complex hull of a point cloud by the Graham scan algorithm.
Example
// Static example
var i, hull,
p = [],
q = [];
p.push( board.create('point', [4, 0], {withLabel:false }) );
p.push( board.create('point', [0, 4], {withLabel:false }) );
p.push( board.create('point', [0, 0], {withLabel:false }) );
p.push([-1, 0]);
p.push([-3, -3]);
hull = JXG.Math.Geometry.GrahamScan(p);
for (i = 0; i < hull.length; i++) {
console.log("JSXGraph example:", hull[i]);
q.push(hull[i].c);
}
board.create('polygon', q);
// Output:
// { i: 4, c: [1, -3, 3]}
// { i: 0, c: [1, 4, 0]}
// { i: 1, c: [1, 0, 4]}
Parameters
| Name | Type | Description |
|---|---|---|
points |
Array | An array containing Point, JXG.Coords, and/or arrays. |
Returns
List of objects {i: index, c: coords} containing the convex hull points
in form of the index in the original input array and a coords array.
- Type
- Array
Details
- Source
- math/geometry.js, line 727
(static) _bezierBbox(curve) → {Array}
Computes the bounding box [minX, maxY, maxX, minY] of a Bezier curve segment from its control points.
Parameters
| Name | Type | Description |
|---|---|---|
curve |
Array | Array of four coordinate arrays of length 2 defining a Bezier curve segment, i.e. [[x0,y0], [x1,y1], [x2,y2], [x3,y3]]. |
Returns
Bounding box [minX, maxY, maxX, minY]
- Type
- Array
Details
- Source
- math/geometry.js, line 3101
(static) _bezierLineMeetSubdivision(testSegment)
Parameters
| Name | Type | Description |
|---|---|---|
testSegment |
Boolean | Test if intersection has to be inside of the segment or somewhere on the line defined by the segment |
Details
- Source
- math/geometry.js, line 3253
(private, static) _bezierListConcat()
Append list of intersection points to a list.
Details
- Source
- math/geometry.js, line 3135
(static) _bezierMeetSubdivision(red, blue, level) → {Array}
Find intersections of two Bezier curve segments by recursive subdivision. Below maxlevel determine intersections by intersection line segments.
Parameters
| Name | Type | Description |
|---|---|---|
red |
Array | Array of four coordinate arrays of length 2 defining the first Bezier curve segment, i.e. [[x0,y0], [x1,y1], [x2,y2], [x3,y3]]. |
blue |
Array | Array of four coordinate arrays of length 2 defining the second Bezier curve segment, i.e. [[x0,y0], [x1,y1], [x2,y2], [x3,y3]]. |
level |
Number | Recursion level |
Returns
List of intersection points (up to nine). Each intersection point is an array of length three (homogeneous coordinates) plus preimages.
- Type
- Array
Details
- Source
- math/geometry.js, line 3175
(static) _bezierOverlap(bb1, bb2) → {Boolean}
Decide if two Bezier curve segments overlap by comparing their bounding boxes.
Parameters
| Name | Type | Description |
|---|---|---|
bb1 |
Array | Bounding box of the first Bezier curve segment |
bb2 |
Array | Bounding box of the second Bezier curve segment |
Returns
true if the bounding boxes overlap, false otherwise.
- Type
- Boolean
Details
- Source
- math/geometry.js, line 3127
(static) _bezierSplit(curve) → {Array}
Splits a Bezier curve segment defined by four points into two Bezier curve segments. Dissection point is t=1/2.
Parameters
| Name | Type | Description |
|---|---|---|
curve |
Array | Array of four coordinate arrays of length 2 defining a Bezier curve segment, i.e. [[x0,y0], [x1,y1], [x2,y2], [x3,y3]]. |
Returns
Array consisting of two coordinate arrays for Bezier curves.
- Type
- Array
Details
- Source
- math/geometry.js, line 3076
(private, static) _meetCurveCurveIterative(c1, c2, low, up, i, testSegment) → {Array}
Return a list of the (at most) first i intersection points of two curves. Computed iteratively.
Parameters
| Name | Type | Description |
|---|---|---|
c1 |
Curve | Line | Circle | Curve, Line or Circle |
c2 |
Curve | Line | Circle | Curve, Line or Circle |
low |
Number | Lower bound of the search domain (between [0, 1]) |
up |
Number | Upper bound of the search domain (between [0, 1]) |
i |
Number | Return a list of the first i intersection points |
testSegment |
Boolean | If true require that t1 and t2 are inside of the allowed bounds. |
Returns
List of the first i intersection points, given by the parameter t.
- Type
- Array
Details
(private, static) _paramsOutOfRange(params, r_u, r_vopt)
Test if parameters are inside of allowed ranges
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
Array | Array of length 1 or 2 |
|
r_u |
Array | First range |
|
r_v |
Array |
<optional> |
Second range |
Returns
Boolean
Details
- Source
- math/geometry.js, line 4306
(static) affineDistance(array1, array2, nopt) → {Number}
Calculates Euclidean distance for two given arrays of the same length. If one of the arrays contains a zero in the first coordinate, and the Euclidean distance is different from zero it is a point at infinity and we return Infinity.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
array1 |
Array | Array containing elements of type number. |
|
array2 |
Array | Array containing elements of type number. |
|
n |
Number |
<optional> |
Length of the arrays. Default is the minimum length of the given arrays. |
Returns
Euclidean (affine) distance of the given vectors.
- Type
- Number
Details
- Source
- math/geometry.js, line 511
(static) affineRatio(a, b, c) → {Number}
Affine ratio of three collinear points a, b, c: (c - a) / (b - a). If r > 1 or r < 0 then c is outside of the segment ab.
Parameters
| Name | Type | Description |
|---|---|---|
a |
Array | JXG.Coords | |
b |
Array | JXG.Coords | |
c |
Array | JXG.Coords |
Returns
affine ratio (c - a) / (b - a)
- Type
- Number
Details
- Source
- math/geometry.js, line 535
(static) angle(A, B, C) → {Number}
Calculates the angle defined by the points A, B, C.
Parameters
| Name | Type | Description |
|---|---|---|
A |
Point | Array | A point or [x,y] array. |
B |
Point | Array | Another point or [x,y] array. |
C |
Point | Array | A circle - no, of course the third point or [x,y] array. |
Returns
The angle in radian measure.
- Type
- Number
Details
- Deprecated
- Use JXG.Math.Geometry.rad instead.
- See
- Source
- math/geometry.js, line 77
(static) angleBisector(A, B, C, boardopt) → {JXG.Coords}
Calculates a point on the bisection line between the three points A, B, C. As a result, the bisection line is defined by two points: Parameter B and the point with the coordinates calculated in this function. Does not work for ideal points.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
A |
Point | Point |
||
B |
Point | Point |
||
C |
Point | Point |
||
board |
<optional> |
A.board
|
Reference to the board |
Returns
Coordinates of the second point defining the bisection.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 186
(static) bezierArc(A, B, C, withLegs, sgn)
Generate the defining points of a 3rd degree bezier curve that approximates a circle sector defined by three coordinate points A, B, C, each defined by an array of length three. The coordinate arrays are given in homogeneous coordinates.
Parameters
| Name | Type | Description |
|---|---|---|
A |
Array | First point |
B |
Array | Second point (intersection point) |
C |
Array | Third point |
withLegs |
Boolean | Flag. If true the legs to the intersection point are part of the curve. |
sgn |
Number | Wither 1 or -1. Needed for minor and major arcs. In case of doubt, use 1. |
Details
- Source
- math/geometry.js, line 3468
(static) calcLabelQuadrant(angle)
Calculates the visProp.position corresponding to a given angle.
Parameters
| Name | Type | Description |
|---|---|---|
angle |
number | angle in radians. Must be in range (-2pi,2pi). |
Details
- Source
- math/geometry.js, line 1530
(static) calcLineDelimitingPoints(el, point1, point2)
A line can be a segment, a straight, or a ray. so it is not always delimited by point1 and point2.
This method adjusts the line's delimiting points taking into account its nature, the viewport defined by the board.
A segment is delimited by start and end point, a straight line or ray is delimited until it meets the boards boundaries. However, if the line has infinite ticks, it will be delimited by the projection of the boards vertices onto itself.
Parameters
| Name | Type | Description |
|---|---|---|
el |
Line | Reference to a line object, that needs calculation of start and end point. |
point1 |
JXG.Coords | Coordinates of the point where line drawing begins. This value is calculated and set by this method. |
point2 |
JXG.Coords | Coordinates of the point where line drawing ends. This value is calculated and set by this method. |
Details
- See
- Source
- math/geometry.js, line 1350
(static) calcStraight(el, point1, point2, margin)
A line can be a segment, a straight, or a ray. So it is not always delimited by point1 and point2 calcStraight determines the visual start point and end point of the line. A segment is only drawn from start to end point, a straight line is drawn until it meets the boards boundaries.
Parameters
| Name | Type | Description |
|---|---|---|
el |
Line | Reference to a line object, that needs calculation of start and end point. |
point1 |
JXG.Coords | Coordinates of the point where line drawing begins. This value is calculated and set by this method. |
point2 |
JXG.Coords | Coordinates of the point where line drawing ends. This value is calculated and set by this method. |
margin |
Number | Optional margin, to avoid the display of the small sides of lines. |
Returns
null
Details
- See
- Source
- math/geometry.js, line 1182
(static) circumcenter(point1, point2, point3, boardopt) → {JXG.Coords}
Calculates the center of the circumcircle of the three given points.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
point1 |
Point | Point |
||
point2 |
Point | Point |
||
point3 |
Point | Point |
||
board |
JXG.Board |
<optional> |
point1.board
|
Reference to the board |
Returns
Coordinates of the center of the circumcircle of the given points.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 456
(static) circumcenterMidpoint()
Details
- Deprecated
- Please use JXG.Math.Geometry.circumcenter instead.
- Source
- math/geometry.js, line 443
(static) convexHull(points, returnCoordsopt) → {Array}
Calculate the complex hull of a point cloud by the Graham scan algorithm.
Examples
// Static example
var i, hull,
p = [];
p.push( board.create('point', [4, 0], {withLabel:false }) );
p.push( board.create('point', [0, 4], {withLabel:false }) );
p.push( board.create('point', [0, 0], {withLabel:false }) );
p.push( board.create('point', [1, 1], {withLabel:false }) );
hull = JXG.Math.Geometry.convexHull(p);
for (i = 0; i < hull.length; i++) {
hull[i].setAttribute({color: 'blue'});
}
// Dynamic version using returnCoords==true: drag the points
var p = [];
p.push( board.create('point', [4, 0], {withLabel:false }) );
p.push( board.create('point', [0, 4], {withLabel:false }) );
p.push( board.create('point', [0, 0], {withLabel:false }) );
p.push( board.create('point', [1, 1], {withLabel:false }) );
var c = board.create('curve', [[], []], {fillColor: 'yellow', fillOpacity: 0.3});
c.updateDataArray = function() {
var i,
hull = JXG.Math.Geometry.convexHull(p, true);
this.dataX = [];
this.dataY = [];
for (i = 0; i < hull.length; i ++) {
this.dataX.push(hull[i][1]);
this.dataY.push(hull[i][2]);
}
this.dataX.push(hull[0][1]);
this.dataY.push(hull[0][2]);
};
board.update();
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
points |
Array | An array containing Point, JXG.Coords, and/or arrays. |
||
returnCoords |
Boolean |
<optional> |
false
|
If true, return an array of coords. Otherwise return a list of pointers to the input list elements. That is, if the input is a list of JXG.Point elements, the returned list will contain the points that form the convex hull. |
Returns
List containing the convex hull. Format depends on returnCoords.
- Type
- Array
Details
- See
- Source
- math/geometry.js, line 1012
(private, static) coordsOnArc(arc, coords) → {Boolean}
Returns true if the coordinates are on the arc element, false otherwise. Usually, coords is an intersection on the circle line. Now it is decided if coords are on the circle restricted to the arc line.
Parameters
| Name | Type | Description |
|---|---|---|
arc |
Arc | arc or sector element |
coords |
JXG.Coords | Coords object of an intersection |
Returns
- Type
- Boolean
Details
- Source
- math/geometry.js, line 2133
(static) det3p(p1, p2, q) → {Number}
Determinant of three points in the Euclidean plane. Zero, if the points are collinear. Used to determine of a point q is left or right to a segment defined by points p1 and p2.
Non-homogeneous version.
Parameters
| Name | Type | Description |
|---|---|---|
p1 |
Array | Point | First point or its coordinates of the segment. Point object or array of length 3. First (homogeneous) coordinate is equal to 1. |
p2 |
Array | Point | Second point or its coordinates of the segment. Point object or array of length 3. First (homogeneous) coordinate is equal to 1. |
q |
Array | Point | Point or its coordinates. Point object or array of length 3. First (homogeneous) coordinate is equal to 1. |
Returns
Signed area of the triangle formed by these three points.
- Type
- Number
Details
- See
- Source
- math/geometry.js, line 1627
(static) distPointLine(point, line) → {Number}
Calculates the distance of a point to a line. The point and the line are given by homogeneous coordinates. For lines this can be line.stdform.
Parameters
| Name | Type | Description |
|---|---|---|
point |
Array | Homogeneous coordinates of a point. |
line |
Array | Homogeneous coordinates of a line ([C,A,B] where Ax+By+C*z=0). |
Returns
Distance of the point to the line.
- Type
- Number
Details
- Source
- math/geometry.js, line 4082
(static) distPointSegment(q, p1, p2) → {Number}
Determine the (Euclidean) distance between a point q and a line segment defined by two points p1 and p2. In case p1 equals p2, the distance to this point is returned.
Parameters
| Name | Type | Description |
|---|---|---|
q |
Array | Homogeneous coordinates of q |
p1 |
Array | Homogeneous coordinates of p1 |
p2 |
Array | Homogeneous coordinates of p2 |
Returns
Distance of q to line segment [p1, p2]
- Type
- Number
Details
- Source
- math/geometry.js, line 4109
(static) distance(array1, array2, nopt) → {Number}
Calculates the Euclidean distance for two given arrays of the same length.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
array1 |
Array | Array of Number |
|
array2 |
Array | Array of Number |
|
n |
Number |
<optional> |
Length of the arrays. Default is the minimum length of the given arrays. |
Returns
Euclidean distance of the given vectors.
- Type
- Number
Details
- Source
- math/geometry.js, line 487
(static) intersectionFunction(board, el1, el2, i) → {function}
Generate the function which computes the coordinates of the intersection point. Primarily used in JXG.Point.createIntersectionPoint. The result will be a intersection point on el1 and el2. i determines the intersection point if two points are available:
i==0: use the positive square root,i==1: use the negative square root.
Parameters
| Name | Type | Description |
|---|---|---|
board |
JXG.Board | object |
el1 |
Line | Circle | |
el2 |
JXG.Line | Circle | |
i |
Number | function | |
alwaysintersect. |
Boolean | Flag that determines if segments and arc can have an outer intersection point on their defining line or circle. |
Returns
Function returning a JXG.Coords object that determines the intersection point.
- Type
- function
Details
- See
-
- JXG.Point.createIntersectionPoint
- Source
- math/geometry.js, line 1877
(static) intersectionFunction3D(el1, el2) → {Array}
Generate the function which computes the data of the intersection between
- plane3d, plane3d,
- plane3d, sphere3d,
- sphere3d, plane3d,
- sphere3d, sphere3d
Parameters
| Name | Type | Description |
|---|---|---|
el1 |
JXG.GeometryElement3D | Plane or sphere element |
el2 |
JXG.GeometryElement3D | Plane or sphere element |
Returns
of functions needed as input to create the intersecting line or circle.
- Type
- Array
Details
- Source
- math/geometry.js, line 4161
(static) isConvex(points) → {Boolean}
Determine if a polygon or a path element is convex:
A polygon is convex if for every pair of points, the line segment connecting them does not intersect an edge of the polygon in one point. A single line segment, a single point, or the empty set is considered as convex. A necessary condition for a polygon to be convex that the angle sum of its interior angles equals ± 2 π.
A path element might be specified as an array of coordinate arrays or JXG.Coords. See the discussion at stackoverflow.
Example
var pol = board.create('polygon', [
[-1, -1],
[3, -1],
[4, 2],
[3, 3],
[0, 4],
[-3, 1]
], {
vertices: {
color: 'blue',
snapToGrid: true
}
});
console.log("JSXGraph example:", JXG.Math.Geometry.isConvex(pol));
// > true
Parameters
| Name | Type | Description |
|---|---|---|
points |
Array | Polygon | PolygonalChain | Polygon or list of coordinates |
Returns
true if convex
- Type
- Boolean
Details
- Source
- math/geometry.js, line 1102
(static) isSameDir(p1, p2, i1, i2) → {Boolean}
The vectors p2-p1 and i2-i1 are supposed to be collinear. If their cosine is positive
they point into the same direction otherwise they point in opposite direction.
Parameters
| Name | Type | Description |
|---|---|---|
p1 |
JXG.Coords | |
p2 |
JXG.Coords | |
i1 |
JXG.Coords | |
i2 |
JXG.Coords |
Returns
True, if p2-p1 and i2-i1 point into the same direction
- Type
- Boolean
Details
- Source
- math/geometry.js, line 1548
(static) isSameDirection(start, p, s) → {Boolean}
If you're looking from point "start" towards point "s" and you can see the point "p", return true. Otherwise return false.
Parameters
| Name | Type | Description |
|---|---|---|
start |
JXG.Coords | The point you're standing on. |
p |
JXG.Coords | The point in which direction you're looking. |
s |
JXG.Coords | The point that should be visible. |
Returns
True, if from start the point p is in the same direction as s is, that means s-start = k*(p-start) with k>=0.
- Type
- Boolean
Details
- Source
- math/geometry.js, line 1575
(static) meet(el1, el2, i, board) → {JXG.Coords}
Computes the intersection of a pair of lines, circles or both. It uses the internal data array stdform of these elements.
Parameters
| Name | Type | Description |
|---|---|---|
el1 |
Array | stdform of the first element (line or circle) |
el2 |
Array | stdform of the second element (line or circle) |
i |
Number | function | Index of the intersection point that should be returned. |
board |
Reference to the board. |
Returns
Coordinates of one of the possible two or more intersection points. Which point will be returned is determined by i.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 2164
(static) meet3Planes(n1, d1, n2, d2, n3, d3) → {Array}
Intersecting point of three planes in 3D. The planes are given in Hesse normal form.
Parameters
| Name | Type | Description |
|---|---|---|
n1 |
Array | Hesse normal form vector of plane 1 |
d1 |
Number | Hesse normal form right hand side of plane 1 |
n2 |
Array | Hesse normal form vector of plane 2 |
d2 |
Number | Hesse normal form right hand side of plane 2 |
n3 |
Array | Hesse normal form vector of plane 1 |
d3 |
Number | Hesse normal form right hand side of plane 3 |
Returns
Coordinates array of length 4 of the intersecting point
- Type
- Array
Details
- Source
- math/geometry.js, line 4195
(static) meetBezierCurveRedBlueSegments(red, blue, nr) → {Array}
Find the nr-th intersection point of two Bezier curves, i.e. curves with bezierDegree == 3.
Parameters
| Name | Type | Description |
|---|---|---|
red |
Curve | Curve with bezierDegree == 3 |
blue |
Curve | Curve with bezierDegree == 3 |
nr |
Number | function | The number of the intersection point which should be returned. |
Returns
The homogeneous coordinates of the nr-th intersection point.
- Type
- Array
Details
- Source
- math/geometry.js, line 3345
(static) meetBeziersegmentBeziersegment(red, blue, testSegment) → {Array}
Find the nr-th intersection point of two Bezier curve segments.
Parameters
| Name | Type | Description |
|---|---|---|
red |
Array | Array of four coordinate arrays of length 2 defining the first Bezier curve segment, i.e. [[x0,y0], [x1,y1], [x2,y2], [x3,y3]]. |
blue |
Array | Array of four coordinate arrays of length 2 defining the second Bezier curve segment, i.e. [[x0,y0], [x1,y1], [x2,y2], [x3,y3]]. |
testSegment |
Boolean | Test if intersection has to be inside of the segment or somewhere on the line defined by the segment |
Returns
Array containing the list of all intersection points as homogeneous coordinate arrays plus preimages [x,y], t_1, t_2] of the two Bezier curve segments.
- Type
- Array
Details
- Source
- math/geometry.js, line 3315
(static) meetCircleCircle(circ1, circ2, i, board) → {JXG.Coords}
Intersection of two circles.
Parameters
| Name | Type | Description |
|---|---|---|
circ1 |
Array | stdform of the first circle |
circ2 |
Array | stdform of the second circle |
i |
number | function | number of the returned intersection point. i==0: use the positive square root, i==1: use the negative square root. |
board |
JXG.Board | Reference to the board. |
Returns
Coordinates of the intersection point
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 2357
(static) meetCurveCurve(c1, c2, nr, t2ini, boardopt, methodopt, testSegment) → {JXG.Coords}
Compute an intersection of the curves c1 and c2. We want to find values t1, t2 such that \(c_1(t_1) = c_2(t_2)\), i.e. \[(c_{1,x}(t_1) - c_{2,x}(t_2), c_{1,y}(t_1) - c_{2,y}(t_2)) = (0, 0).\]
Available methods:
- discrete, segment-wise intersections
- generalized damped Newton-Raphson
Segment-wise intersection is more stable, but has problems with tangent points. Damped Newton-Raphson converges very rapidly but sometimes behaves chaotic.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
c1 |
Curve | Line | Circle | Curve, Line or Circle |
||
c2 |
Curve | Line | Circle | Curve, Line or Circle |
||
nr |
Number | function | the nr-th intersection point will be returned. For backwards compatibility: if method='newton' and nr is not an integer, JXG.Math.Numerics.generalizedNewton is called directly with nr as start value (not recommended). |
||
t2ini |
Number | not longer used. Must be supplied and is ignored. |
||
board |
JXG.Board |
<optional> |
c1.board
|
Reference to a board object. |
method |
String |
<optional> |
Intersection method, possible values are 'newton' and 'segment'. If both curves are given by functions (assumed to be continuous), 'newton' is the default, otherwise 'segment' is the default. |
|
testSegment |
Boolean | If true require that the intersection is inside of the allowed bounds for both elements (in _meetCurveCurveIterative) |
Returns
intersection point
- Type
- JXG.Coords
Details
(private, static) meetCurveCurveDiscrete(c1, c2, nr, boardopt) → {JXG.Coords}
Segment-wise search for the nr-th intersection of two curves. testSegment is always assumed to be true.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
c1 |
Curve | Line | Circle | Curve, Line or Circle |
||
c2 |
Curve | Line | Circle | Curve, Line or Circle |
||
nr |
Number | the nr-th intersection point will be returned |
||
board |
JXG.Board |
<optional> |
c1.board
|
Reference to a board object |
Returns
intersection as Coords object
- Type
- JXG.Coords
Details
(private, static) meetCurveCurveNewton(c1, c2, range, testSegment) → {Array}
Apply Newton-Raphson to search for an intersection of two curves in a given range of the first curve.
Parameters
| Name | Type | Description |
|---|---|---|
c1 |
Curve | Line | Circle | Curve, Line or Circle |
c2 |
Curve | Line | Circle | Curve, Line or Circle |
range |
Array | Domain for the search of an intersection. The start value for the search is chosen to be inside of that range. |
testSegment |
Boolean | If true require that t1 and t2 are inside of the allowed bounds. |
Returns
[[z, x, y], t1, t2, t, ||c1[t1]-c2[t2]||**2]. The last entry is set to 10000 if the intersection is outside of the given domain (range) for the first curve.
- Type
- Array
Details
- See
-
- JXG.Math.Geometry._meetCurveCurveIterative
- JXG.Math.Numerics.generalizedDampedNewton
- JXG.Math.Geometry.meetCurveCurveCobyla
- Source
- math/geometry.js, line 2440
(static) meetCurveLine(el1, el2, nr, boardopt, alwaysIntersect) → {JXG.Coords}
Intersection of curve with line, Order of input does not matter for el1 and el2. From version 0.99.7 on this method calls JXG.Math.Geometry.meetCurveLineDiscrete. If higher precision is needed, JXG.Math.Geometry.meetCurveLineContinuous has to be used.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
el1 |
Curve | Line | Curve or Line |
||
el2 |
Curve | Line | Curve or Line |
||
nr |
Number | function | the nr-th intersection point will be returned. |
||
board |
JXG.Board |
<optional> |
el1.board
|
Reference to a board object. |
alwaysIntersect |
Boolean | If false just the segment between the two defining points are tested for intersection |
Returns
Intersection point. In case no intersection point is detected, the ideal point [0,1,0] is returned.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 2651
(static) meetCurveLineContinuous(cu, li, nr, board, testSegment) → {JXG.Coords}
Intersection of line and curve, continuous case. Finds the nr-th intersection point Uses JXG.Math.Geometry.meetCurveLineDiscrete as a first approximation. A more exact solution is then found with JXG.Math.Numerics.root.
Parameters
| Name | Type | Description |
|---|---|---|
cu |
Curve | Curve |
li |
Line | Line |
nr |
NumberFunction | Will return the nr-th intersection point. |
board |
JXG.Board | |
testSegment |
Boolean | Test if intersection has to be inside of the segment or somewhere on the line defined by the segment |
Returns
Coords object containing the intersection.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 2694
(static) meetCurveLineDiscrete(cu, li, nr, board, testSegment) → {JXG.Coords}
Intersection of line and curve, discrete case. Segments are treated as lines. Finding the nr-th intersection point should work for all nr.
Parameters
| Name | Type | Description |
|---|---|---|
cu |
Curve | |
li |
Line | |
nr |
Number | function | |
board |
JXG.Board | |
testSegment |
Boolean | Test if intersection has to be inside of the segment or somewhere on the line defined by the segment |
Returns
Intersection point. In case no intersection point is detected, the ideal point [0,1,0] is returned.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 2779
(static) meetCurveRedBlueSegments(red, blue, nr)
Find the n-th intersection point of two curves named red (first parameter) and blue (second parameter). We go through each segment of the red curve and search if there is an intersection with a segment of the blue curve. This double loop, i.e. the outer loop runs along the red curve and the inner loop runs along the blue curve, defines the n-th intersection point. The segments are either line segments or Bezier curves of degree 3. This depends on the property bezierDegree of the curves.
This method works also for transformed curves, since only the already transformed points are used.
Parameters
| Name | Type | Description |
|---|---|---|
red |
Curve | |
blue |
Curve | |
nr |
Number | function |
Details
- Source
- math/geometry.js, line 2867
(static) meetLineBoard(line, board, margin) → {Array}
Intersection of the line with the board
Parameters
| Name | Type | Description |
|---|---|---|
line |
Array | stdform of the line in screen coordinates |
board |
JXG.Board | reference to a board. |
margin |
Number | optional margin, to avoid the display of the small sides of lines. |
Returns
[intersection coords 1, intersection coords 2]
- Type
- Array
Details
- Source
- math/geometry.js, line 2192
(static) meetLineCircle(lin, circ, i, board) → {JXG.Coords}
Intersection of line and circle.
Parameters
| Name | Type | Description |
|---|---|---|
lin |
Array | stdform of the line |
circ |
Array | stdform of the circle |
i |
number | function | number of the returned intersection point. i==0: use the positive square root, i==1: use the negative square root. |
board |
JXG.Board | Reference to a board. |
Returns
Coordinates of the intersection point
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 2298
(static) meetLineLine(l1, l2, i, board) → {JXG.Coords}
Intersection of two lines.
Parameters
| Name | Type | Description |
|---|---|---|
l1 |
Array | stdform of the first line |
l2 |
Array | stdform of the second line |
i |
number | unused |
board |
JXG.Board | Reference to the board. |
Returns
Coordinates of the intersection point.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 2278
(static) meetPathPath(path1, path2, n, board) → {JXG.Coords}
Find the n-th intersection point of two pathes, usually given by polygons. Uses parts of the Greiner-Hormann algorithm in JXG.Math.Clip.
Parameters
| Name | Type | Description |
|---|---|---|
path1 |
Circle | Curve | Polygon | |
path2 |
Circle | Curve | Polygon | |
n |
Number | function | |
board |
JXG.Board |
Returns
Intersection point. In case no intersection point is detected, the ideal point [0,0,0] is returned.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 2983
(static) meetPlanePlane(v11, v12, v21, v22) → {Array}
Direction of intersecting line of two planes in 3D.
Parameters
| Name | Type | Description |
|---|---|---|
v11 |
Array | First vector spanning plane 1 (homogeneous coordinates) |
v12 |
Array | Second vector spanning plane 1 (homogeneous coordinates) |
v21 |
Array | First vector spanning plane 2 (homogeneous coordinates) |
v22 |
Array | Second vector spanning plane 2 (homogeneous coordinates) |
Returns
Coordinates array of length 4 of the direction (homogeneous coordinates)
- Type
- Array
Details
- Source
- math/geometry.js, line 4222
(static) meetPolygonLine(path, line, nr, board, alwaysIntersect) → {JXG.Coords}
Find the n-th intersection point between a polygon and a line.
Parameters
| Name | Type | Description |
|---|---|---|
path |
Polygon | |
line |
Line | |
nr |
Number | function | |
board |
JXG.Board | |
alwaysIntersect |
Boolean | If false just the segment between the two defining points of the line are tested for intersection. |
Returns
Intersection point. In case no intersection point is detected, the ideal point [0,0,0] is returned.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 3032
(static) meetSegmentSegment(p1, p2, q1, q2) → {Array}
(Virtual) Intersection of two segments.
Parameters
| Name | Type | Description |
|---|---|---|
p1 |
Array | First point of segment 1 using normalized homogeneous coordinates [1,x,y] |
p2 |
Array | Second point or direction of segment 1 using normalized homogeneous coordinates [1,x,y] or point at infinity [0,x,y], respectively |
q1 |
Array | First point of segment 2 using normalized homogeneous coordinates [1,x,y] |
q2 |
Array | Second point or direction of segment 2 using normalized homogeneous coordinates [1,x,y] or point at infinity [0,x,y], respectively |
Returns
[Intersection point, t, u] The first entry contains the homogeneous coordinates of the intersection point. The second and third entry give the position of the intersection with respect to the definiting parameters. For example, the second entry t is defined by: intersection point = p1 + t * deltaP, where deltaP = (p2 - p1) when both parameters are coordinates, and deltaP = p2 if p2 is a point at infinity. If the two segments are collinear, [[0,0,0], Infinity, Infinity] is returned.
- Type
- Array
Details
- Source
- math/geometry.js, line 2934
(static) perpendicular(line, point, boardopt) → {Array}
Calculates the coordinates of a point on the perpendicular to the given line through the given point.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
line |
Line | A line. |
||
point |
Point | Point which is projected to the line. |
||
board |
JXG.Board |
<optional> |
point.board
|
Reference to the board |
Returns
Array of length two containing coordinates of a point on the perpendicular to the given line through the given point and boolean flag "change".
- Type
- Array
Details
- Source
- math/geometry.js, line 365
(static) pnpoly(x_in, y_in, path, coord_typeopt, board) → {Boolean}
Decides if a point (x,y) is inside of a path / polygon. Does not work correct if the path has hole. In this case, windingNumber is the preferred method. Implements W. Randolf Franklin's pnpoly method.
See https://wrf.ecse.rpi.edu/Research/Short_Notes/pnpoly.html.
Example
var pol = board.create('polygon', [[-1,2], [2,2], [-1,4]]);
var p = board.create('point', [4, 3]);
var txt = board.create('text', [-1, 0.5, function() {
return 'Point A is inside of the polygon = ' +
JXG.Math.Geometry.pnpoly(p.X(), p.Y(), pol.vertices, JXG.COORDS_BY_USER, board);
}]);
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
x_in |
Number | x-coordinate (screen or user coordinates) |
||
y_in |
Number | y-coordinate (screen or user coordinates) |
||
path |
Array | Array of points / coords determining a path, i.e. the vertices of the polygon / path. The array elements do not have to be full points, but have to have a subobject "coords" or should be of type JXG.Coords. |
||
coord_type |
Number |
<optional> |
JXG.COORDS_BY_SCREEN
|
Type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN. Default value is JXG.COORDS_BY_SCREEN. |
board |
JXG.Board | Board object |
Returns
if (x_in, y_in) is inside of the polygon.
- Type
- Boolean
Details
(static) projectCoordsToBeziersegment(pos, curve, start) → {Array}
Finds the coordinates of the closest point on a Bezier segment of a JXG.Curve to a given coordinate array.
Parameters
| Name | Type | Description |
|---|---|---|
pos |
Array | Point to project in homogeneous coordinates. |
curve |
Curve | Curve of type "plot" having Bezier degree 3. |
start |
Number | Number of the Bezier segment of the curve. |
Returns
The coordinates of the projection of the given point on the given Bezier segment and the preimage of the curve which determines the closest point.
- Type
- Array
Details
- Source
- math/geometry.js, line 3696
(static) projectCoordsToCurve(x, y, t, curve, boardopt) → {JXG.Coords}
Calculates the coordinates of the projection of a coordinates pair on a given curve. In case of function graphs this is the intersection point of the curve and the parallel to y-axis through the given point.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
x |
Number | coordinate to project. |
||
y |
Number | coordinate to project. |
||
t |
Number | start value for newtons method |
||
curve |
Curve | Curve on that the point is projected. |
||
board |
JXG.Board |
<optional> |
curve.board
|
Reference to a board. |
Returns
Array containing the coordinates of the projection of the given point on the given curve and the position on the curve.
- Type
- JXG.Coords
Details
(static) projectCoordsToParametric(p, target, n, params) → {Array}
Given the 2D screen coordinates of a point, finds the nearest point on the given parametric curve or surface, and returns its view-space coordinates.
Parameters
| Name | Type | Description |
|---|---|---|
p |
Array | Homogeneous 3D coordinates for which the closest point on the curve point is searched. |
target |
Curve3D | Surface3D | Parametric curve or surface to project to. |
n |
Number | Dimension of the host element to which the coords are projected. |
params |
Array | New position of point on the target (i.e. it is a return value), modified in place during the search, ending up at the nearest point. Usually, point.position is supplied for params. |
Returns
Array of length 4 containing the coordinates of the nearest point on the curve or surface.
- Type
- Array
Details
- Source
- math/geometry.js, line 4323
(static) projectCoordsToPolygon(p, pol) → {Array}
Calculates the coordinates of the closest orthogonal projection of a given coordinate array onto the border of a polygon.
Parameters
| Name | Type | Description |
|---|---|---|
p |
Array | Point to project. |
pol |
Polygon | Polygon element |
Returns
The coordinates of the closest projection of the given point to the border of the polygon.
- Type
- Array
Details
- Source
- math/geometry.js, line 3931
(static) projectCoordsToSegment(p, q1, q2) → {Array}
Calculates the coordinates of the orthogonal projection of a given coordinate array on a given line segment defined by two coordinate arrays.
Parameters
| Name | Type | Description |
|---|---|---|
p |
Array | Point to project. |
q1 |
Array | Start point of the line segment on that the point is projected. |
q2 |
Array | End point of the line segment on that the point is projected. |
Returns
The coordinates of the projection of the given point on the given segment and the factor that determines the projected point as a convex combination of the two endpoints q1 and q2 of the segment.
- Type
- Array
Details
- Source
- math/geometry.js, line 3665
(static) projectPointToBoard(point, boardopt)
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
point |
Point | JXG.Coords | ||
board |
JXG.Board |
<optional> |
Details
- Source
- math/geometry.js, line 4037
(static) projectPointToCircle(point, circle, boardopt) → {JXG.Coords}
Calculates the coordinates of the projection of a given point on a given circle. I.o.w. the nearest one of the two intersection points of the line through the given point and the circles center.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
point |
Point | JXG.Coords | Point to project or coords object to project. |
||
circle |
Circle | Circle on that the point is projected. |
||
board |
JXG.Board |
<optional> |
point.board
|
Reference to the board |
Returns
The coordinates of the projection of the given point on the given circle.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 3592
(static) projectPointToCurve(point, curve, boardopt) → {Array}
Calculates the coordinates of the projection of a given point on a given curve. Uses JXG.Math.Geometry.projectCoordsToCurve.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
point |
Point | Point to project. |
||
curve |
Curve | Curve on that the point is projected. |
||
board |
JXG.Board |
<optional> |
point.board
|
Reference to a board. |
Returns
[JXG.Coords, position] The coordinates of the projection of the given point on the given graph and the relative position on the curve (real number).
- Type
- Array
Details
(static) projectPointToLine(point, line, boardopt) → {JXG.Coords}
Calculates the coordinates of the orthogonal projection of a given point on a given line. I.o.w. the intersection point of the given line and its perpendicular through the given point.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
point |
Point | JXG.Coords | Point to project. |
||
line |
Line | Line on that the point is projected. |
||
board |
JXG.Board |
<optional> |
point.board|board=line.board
|
Reference to a board. |
Returns
The coordinates of the projection of the given point on the given line.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 3633
(static) projectPointToPoint(point, dest) → {JXG.Coords}
Trivial projection of a point to another point.
Parameters
| Name | Type | Description |
|---|---|---|
point |
Point | Point to project (not used). |
dest |
Point | Point on that the point is projected. |
Returns
The coordinates of the projection of the given point on the given circle.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 4028
(static) projectPointToTurtle(point, turtle, boardopt) → {Array}
Calculates the coordinates of the projection of a given point on a given turtle. A turtle consists of one or more curves of curveType 'plot'. Uses JXG.Math.Geometry.projectPointToCurve.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
point |
Point | Point to project. |
||
turtle |
Turtle | on that the point is projected. |
||
board |
JXG.Board |
<optional> |
point.board
|
Reference to a board. |
Returns
[JXG.Coords, position] Array containing the coordinates of the projection of the given point on the turtle and the position on the turtle.
- Type
- Array
Details
- Source
- math/geometry.js, line 3974
(static) projectScreenCoordsToParametric(pScr, target, params) → {Array}
Given a the screen coordinates of a point, finds the point on the given parametric curve or surface which is nearest in screen space, and returns its view-space coordinates.
Parameters
| Name | Type | Description |
|---|---|---|
pScr |
Array | Screen coordinates to project. |
target |
Plane3D | Curve3D | Surface3D | Plane, parametric curve or surface to project to. |
params |
Array | Parameters of point on the target, initially specifying the starting point of the search. The parameters are modified in place during the search, ending up at the nearest point. |
Returns
Array of length 4 containing the coordinates of the nearest point on the curve or surface.
- Type
- Array
Details
- Source
- math/geometry.js, line 4438
(static) rad(A, B, C) → {Number}
Calculates the internal angle defined by the three points A, B, C if you're going from A to C around B counterclockwise.
Parameters
| Name | Type | Description |
|---|---|---|
A |
Point | Array | Point or [x,y] array |
B |
Point | Array | Point or [x,y] array |
C |
Point | Array | Point or [x,y] array |
Returns
Angle in radians.
- Type
- Number
Details
- See
- Source
- math/geometry.js, line 139
(static) reflection(line, point, boardopt) → {JXG.Coords}
Reflects the point along the line.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
line |
Line | Axis of reflection. |
||
point |
Point | Point to reflect. |
||
board |
<optional> |
point.board
|
Reference to the board |
Returns
Coordinates of the reflected point.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 289
(static) reuleauxPolygon(points, nr) → {Array}
Helper function to create curve which displays a Reuleaux polygons.
Example
var A = board.create('point',[-2,-2]);
var B = board.create('point',[0,1]);
var pol = board.create('regularpolygon',[A,B,3], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});
var reuleauxTriangle = board.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol.vertices, 3),
{strokeWidth:6, strokeColor:'#d66d55', fillColor:'#ad5544', highlightFillColor:'#ad5544'});
Parameters
| Name | Type | Description |
|---|---|---|
points |
Array | Array of points which should be the vertices of the Reuleaux polygon. Typically, these point list is the array vertices of a regular polygon. |
nr |
Number | Number of vertices |
Returns
An array containing the two functions defining the Reuleaux polygon and the two values for the start and the end of the paramtric curve. array may be used as parent array of a JXG.Curve.
- Type
- Array
Details
- Source
- math/geometry.js, line 4580
(static) rotation(rotpoint, point, phi, boardopt) → {JXG.Coords}
Computes the new position of a point which is rotated around a second point (called rotpoint) by the angle phi.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
rotpoint |
Point | Center of the rotation |
||
point |
Point | point to be rotated |
||
phi |
Number | rotation angle in arc length |
||
board |
JXG.Board |
<optional> |
point.board
|
Reference to the board |
Returns
Coordinates of the new position.
- Type
- JXG.Coords
Details
- Source
- math/geometry.js, line 330
(static) signedPolygon(p, sortopt) → {Number}
Determine the signed area of a non-self-intersecting polygon. Surveyor's Formula
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
p |
Array | An array containing Point, JXG.Coords, and/or arrays. |
||
sort |
Boolean |
<optional> |
true
|
Returns
- Type
- Number
Details
- Source
- math/geometry.js, line 641
(static) signedTriangle(p1, p2, p3) → {Number}
Signed triangle area of the three points given. It can also be used to test the orientation of the triangle.
- If the return value is \(< 0\), then the point p2 is left of the line [p1, p3] (i.e p3 is right from [p1, p2]).
- If the return value is \(> 0\), then the point p2 is right of the line [p1, p3] (i.e p3 is left from [p1, p2]).
- If the return value is \(= 0\), then the points p1, p2, p3 are collinear.
Parameters
| Name | Type | Description |
|---|---|---|
p1 |
Point | JXG.Coords | Array | |
p2 |
Point | JXG.Coords | Array | |
p3 |
Point | JXG.Coords | Array |
Returns
- Type
- Number
Details
- Source
- math/geometry.js, line 625
(static) sortVertices(p) → {Array}
Sort vertices counter clockwise starting with the first point. Used in Polygon.sutherlandHodgman, Geometry.signedPolygon.
Parameters
| Name | Type | Description |
|---|---|---|
p |
Array | An array containing Point, JXG.Coords, and/or arrays. |
Returns
- Type
- Array
Details
- Source
- math/geometry.js, line 567
(static) trueAngle(A, B, C) → {Number}
Calculates the angle defined by the three points A, B, C if you're going from A to C around B counterclockwise.
Parameters
| Name | Type | Description |
|---|---|---|
A |
Point | Array | Point or [x,y] array |
B |
Point | Array | Point or [x,y] array |
C |
Point | Array | Point or [x,y] array |
Returns
The angle in degrees.
- Type
- Number
Details
- See
- Source
- math/geometry.js, line 127
(static) windingNumber(usrCoords, path, doNotClosePathopt) → {Number}
Winding number of a point in respect to a polygon path.
The point is regarded outside if the winding number is zero, inside otherwise. The algorithm tries to find degenerate cases, i.e. if the point is on the path. This is regarded as "outside". If the point is a vertex of the path, it is regarded as "inside".
Implementation of algorithm 7 from "The point in polygon problem for arbitrary polygons" by Kai Hormann and Alexander Agathos, Computational Geometry, Volume 20, Issue 3, November 2001, Pages 131-144.
Parameters
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
usrCoords |
Array | Homogenous coordinates of the point |
||
path |
Array | Array of points / coords determining a path, i.e. the vertices of the polygon / path. The array elements do not have to be full points, but have to have a subobject "coords" or should be of type JXG.Coords. |
||
doNotClosePath |
Boolean |
<optional> |
false
|
If true the last point of the path is not connected to the first point. This is necessary if the path consists of two or more closed subpaths, e.g. if the figure has a hole. |
Returns
Winding number of the point. The point is regarded outside if the winding number is zero, inside otherwise.
- Type
- Number
Details
- Source
- math/geometry.js, line 1671
Inherited
none