JXG.Math.Geometry Class
Math.Geometry namespace definition
Item Index
Methods
 _bezierBbox
 _bezierLineMeetSubdivision
 _bezierListConcat
 _bezierMeetSubdivision
 _bezierOverlap
 _bezierSplit
 affineDistance
 angle deprecated
 angleBisector
 bezierArc
 bezierSegmentEval
 calcLineDelimitingPoints
 calcStraight
 circumcenter
 circumcenterMidpoint deprecated
 distance
 distPointLine
 GrahamScan
 intersectionFunction
 isSameDir
 isSameDirection
 meet
 meetBezierCurveRedBlueSegments
 meetBeziersegmentBeziersegment
 meetCircleCircle
 meetCurveCurve
 meetCurveLine
 meetCurveLineContinuous
 meetCurveLineContinuousOld deprecated
 meetCurveLineDiscrete
 meetCurveRedBlueSegments
 meetLineBoard
 meetLineCircle
 meetLineLine
 meetSegmentSegment
 perpendicular
 projectCoordsToBeziersegment
 projectCoordsToCurve
 projectCoordsToPolygon
 projectCoordsToSegment
 projectPointToBoard
 projectPointToCircle
 projectPointToCurve
 projectPointToLine
 projectPointToPoint
 projectPointToTurtle
 rad
 reflection
 releauxPolygon
 rotation
 signedPolygon
 signedTriangle
 sortVertices
 trueAngle
Methods
_bezierBbox

curve
Computes the bounding box [minX, maxY, maxX, minY] of a Bezier curve segment from its control points.
Parameters:

curve
ArrayArray 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]
_bezierLineMeetSubdivision

red

blue

level

testSegment
Find intersections of Bezier curve segments with a line by recursive subdivision. Below maxlevel determine intersections by intersection line segments.
Parameters:

red
ArrayArray of four coordinate arrays of length 2 defining the first Bezier curve segment, i.e. [[x0,y0], [x1,y1], [x2,y2], [x3,y3]].

blue
ArrayArray of four coordinate arrays of length 2 defining the second Bezier curve segment, i.e. [[x0,y0], [x1,y1], [x2,y2], [x3,y3]].

level
NumberRecursion level

testSegment
BooleanTest if intersection has to be inside of the segment or somewhere on the line defined by the segment
Returns:
_bezierListConcat
()
private
Append list of intersection points to a list.
_bezierMeetSubdivision

red

blue

level
Find intersections of two Bezier curve segments by recursive subdivision. Below maxlevel determine intersections by intersection line segments.
Parameters:

red
ArrayArray of four coordinate arrays of length 2 defining the first Bezier curve segment, i.e. [[x0,y0], [x1,y1], [x2,y2], [x3,y3]].

blue
ArrayArray of four coordinate arrays of length 2 defining the second Bezier curve segment, i.e. [[x0,y0], [x1,y1], [x2,y2], [x3,y3]].

level
NumberRecursion level
Returns:
List of intersection points (up to nine). Each intersction point is an array of length three (homogeneous coordinates) plus preimages.
_bezierOverlap

bb1

bb2
Decide if two Bezier curve segments overlap by comparing their bounding boxes.
Parameters:
Returns:
true if the bounding boxes overlap, false otherwise.
_bezierSplit

curve
Splits a Bezier curve segment defined by four points into two Bezier curve segments. Dissection point is t=1/2.
Parameters:

curve
ArrayArray 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.
affineDistance

array1

array2

[n]
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:
Returns:
Euclidean (affine) distance of the given vectors.
angle

A

B

C
Calculates the angle (in radians) defined by the points A, B, C.
Parameters:

A
JXG.Point,ArrayA point or [x,y] array.

B
JXG.Point,ArrayAnother point or [x,y] array.

C
JXG.Point,ArrayA circle  no, of course the third point or [x,y] array.
Returns:
The angle in radian measure.
See also:
 #rad
 #trueAngle
angleBisector

A

B

C

[board=A.board]
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:
Returns:
Coordinates of the second point defining the bisection.
bezierArc

A

B

C

withLegs

sgn
Generate the defining points of a 3rd degree bezier curve that approximates a circle sector defined by three arrays A, B,C, each of length three. The coordinate arrays are given in homogeneous coordinates.
Parameters:
Returns:
Array consosting of one array of xcoordinates and one array of ycoordinates,
Suitable for updataDataArray
.
bezierSegmentEval

t

curve
Eval Bezier curve segment at value t.
Parameters:
Returns:
Value of the Bezier curve at t given as Euclidean coordinates in the form [1, x, y].
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:

el
JXG.LineReference to a line object, that needs calculation of start and end point.

point1
JXG.CoordsCoordinates of the point where line drawing begins. This value is calculated and set by this method.

point2
JXG.CoordsCoordinates of the point where line drawing ends. This value is calculated and set by this method.
See also:
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:

el
JXG.LineReference to a line object, that needs calculation of start and end point.

point1
JXG.CoordsCoordinates of the point where line drawing begins. This value is calculated and set by this method.

point2
JXG.CoordsCoordinates of the point where line drawing ends. This value is calculated and set by this method.

margin
NumberOptional margin, to avoid the display of the small sides of lines.
See also:
circumcenter

point1

point2

point3

[board=point1.board]
Calculates the center of the circumcircle of the three given points.
Parameters:
Returns:
Coordinates of the center of the circumcircle of the given points.
distance

array1

array2

[n]
Calculates the euclidean norm for two given arrays of the same length.
Parameters:
Returns:
Euclidean distance of the given vectors.
distPointLine

point

line
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:
Returns:
Distance of the point to the line.
GrahamScan

points
Calculate the complex hull of a point cloud.
Parameters:

points
ArrayAn array containing {@link JXG.Point}, {@link JXG.Coords}, and/or arrays.
Returns:
intersectionFunction

board

el1,el2,i

alwaysintersect.
Generate the function which computes the coordinates of the intersection point. Primarily used in undefined.
Parameters:

board
JXG.Boardobject

el1,el2,i
JXG.Line,JXG.Circle_JXG.Line,JXG.Circle_NumberThe 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.

alwaysintersect.
BooleanFlag that determines if segements and arc can have an outer intersection point on their defining line or circle.
Returns:
Function returning a {@see JXG.Coords} object that determines the intersection point.
isSameDir

p1

p2

i1

i2
The vectors p2p1 and i2i1 are supposed to be collinear. If their cosine is positive they point into the same direction otherwise they point in opposite direction.
Parameters:

p1
JXG.Coords 
p2
JXG.Coords 
i1
JXG.Coords 
i2
JXG.Coords
Returns:
True, if p2p1 and i2i1 point into the same direction
isSameDirection

start

p

s
If you're looking from point "start" towards point "s" and can see the point "p", true is returned. Otherwise false.
Parameters:

start
JXG.CoordsThe point you're standing on.

p
JXG.CoordsThe point in which direction you're looking.

s
JXG.CoordsThe point that should be visible.
Returns:
True, if from start the point p is in the same direction as s is, that means sstart = k*(pstart) with k>=0.
meet

el1

el2

i

board
Computes the intersection of a pair of lines, circles or both. It uses the internal data array stdform of these elements.
Parameters:
Returns:
Coordinates of one of the possible two or more intersection points. Which point will be returned is determined by i.
meetBezierCurveRedBlueSegments

red

blue

nr
Find the nrth intersection point of two Bezier curves, i.e. curves with bezierDegree == 3.
Parameters:
Returns:
The homogeneous coordinates of the nrth intersection point.
meetBeziersegmentBeziersegment

red

blue

testSegment
Find the nrth intersection point of two Bezier curve segments.
Parameters:

red
ArrayArray of four coordinate arrays of length 2 defining the first Bezier curve segment, i.e. [[x0,y0], [x1,y1], [x2,y2], [x3,y3]].

blue
ArrayArray of four coordinate arrays of length 2 defining the second Bezier curve segment, i.e. [[x0,y0], [x1,y1], [x2,y2], [x3,y3]].

testSegment
BooleanTest 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.
meetCircleCircle

circ1

circ2

i

board
Intersection of two circles.
Parameters:
Returns:
Coordinates of the intersection point
meetCurveCurve

c1

c2

nr

t2ini

[board=c1.board]

[method='segment']
Compute an intersection of the curves c1 and c2. We want to find values t1, t2 such that c1(t1) = c2(t2), i.e. (c1_x(t1)c2_x(t2),c1_y(t1)c2_y(t2)) = (0,0).
Methods: segmentwise intersections (default) or generalized Newton method.
Parameters:

c1
JXG.CurveCurve, Line or Circle

c2
JXG.CurveCurve, Line or Circle

nr
Numberthe nrth intersection point will be returned.

t2ini
Numbernot longer used.

[board=c1.board]
JXG.Board optionalReference to a board object.

[method='segment']
String optionalIntersection method, possible values are 'newton' and 'segment'.
Returns:
intersection point
meetCurveLine

el1

el2

nr

[board=el1.board]

alwaysIntersect
Intersection of curve with line, Order of input does not matter for el1 and el2.
Parameters:

el1
JXG.Curve,JXG.LineCurve or Line

el2
JXG.Curve,JXG.LineCurve or Line

nr
Numberthe nrth intersection point will be returned.

[board=el1.board]
JXG.Board optionalReference to a board object.

alwaysIntersect
BooleanIf 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.
meetCurveLineContinuous

cu

li

nr

board
Intersection of line and curve, continuous case. Finds the nrthe intersection point Uses JXG.Math.Geometry#meetCurveLineDiscrete as a first approximation. A more exact solution is then found with undefined.
Parameters:
Returns:
Intersection point
meetCurveLineContinuousOld

cu

li

nr

board
Intersection of line and curve, continuous case. Segments are treated as lines. Finding the nrthe intersection point works for nr=0,1 only.
BUG: does not respect cu.minX() and cu.maxX()
meetCurveLineDiscrete

cu

li

nr

board

testSegment
Intersection of line and curve, discrete case. Segments are treated as lines. Finding the nrth intersection point should work for all nr.
Parameters:
Returns:
Intersection point. In case no intersection point is detected, the ideal point [0,1,0] is returned.
meetCurveRedBlueSegments

red

blue

nr
Find the nth 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 segemnt 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 nth intersection point. The segments are either line segments or Bezier curves of degree 3. This depends on the property bezierDegree of the curves.
meetLineBoard

line

board

margin
Intersection of the line with the board
Parameters:
Returns:
[intersection coords 1, intersection coords 2]
meetLineCircle

lin

circ

i

board
Intersection of line and circle.
Parameters:
Returns:
Coordinates of the intersection point
meetLineLine

l1

l2

i

board
Intersection of two lines.
Parameters:
Returns:
Coordinates of the intersection point.
meetSegmentSegment

p1

p2

q1

q2
Intersection of two segments.
Parameters:
Returns:
[Intersection point, t, u] The first entry contains the homogeneous coordinates of the intersection point. The second and third entry gives the position of the intersection between the two defining points. For example, the second entry t is defined by: intersection point = t*p1 + (1t)*p2.
perpendicular

line

point

[board=point.board]
Calculates the coordinates of a point on the perpendicular to the given line through the given point.
Parameters:
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".
projectCoordsToBeziersegment

pos

curve

start
Finds the coordinates of the closest point on a Bezier segment of a JXG.Curve to a given coordinate array.
Parameters:
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.
projectCoordsToCurve

x

y

t

curve

[board=curve.board]
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 yaxis through the given point.
Parameters:
Returns:
Array containing the coordinates of the projection of the given point on the given graph and the position on the curve.
See also:
 #projectPointToCurve
projectCoordsToPolygon

p

pol
Calculates the coordinates of the closest orthogonal projection of a given coordinate array onto the border of a polygon.
Parameters:

p
ArrayPoint to project.

pol
JXG.PolygonPolygon element
Returns:
The coordinates of the closest projection of the given point to the border of the polygon.
projectCoordsToSegment

p

q1

q2
Calculates the coordinates of the orthogonal projection of a given coordinate array on a given line segment defined by two coordinate arrays.
Parameters:
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.
projectPointToBoard

point

[board]
Parameters:

point
JXG.Point  JXG.Coords 
[board]
JXG.Board optional
projectPointToCircle

point

circle

[board=point.board]
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:

point
JXG.Point,JXG.CoordsPoint to project or coords object to project.

circle
JXG.CircleCircle on that the point is projected.

[board=point.board]
JXG.Board optionalReference to the board
Returns:
The coordinates of the projection of the given point on the given circle.
projectPointToCurve

point

curve

[board=point.board]
Calculates the coordinates of the projection of a given point on a given curve. Uses undefined.
Parameters:
Returns:
The coordinates of the projection of the given point on the given graph.
See also:
 #projectCoordsToCurve
projectPointToLine

point

line

[board=point.board]
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:
Returns:
The coordinates of the projection of the given point on the given line.
projectPointToPoint

point

dest
Trivial projection of a point to another point.
Parameters:
Returns:
The coordinates of the projection of the given point on the given circle.
projectPointToTurtle

point

turtle

[board=point.board]
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 undefined.
Parameters:

point
JXG.PointPoint to project.

turtle
JXG.Turtleon that the point is projected.

[board=point.board]
JXG.Board optionalReference to a board.
Returns:
The coordinates of the projection of the given point on the given turtle.
rad

A

B

C
Calculates the internal angle defined by the three points A, B, C if you're going from A to C around B counterclockwise.
Parameters:

A
JXG.Point,ArrayPoint or [x,y] array

B
JXG.Point,ArrayPoint or [x,y] array

C
JXG.Point,ArrayPoint or [x,y] array
Returns:
Angle in radians.
See also:
 #trueAngle
reflection

line

point

[board=point.board]
Reflects the point along the line.
Parameters:
Returns:
Coordinates of the reflected point.
releauxPolygon

points

nr
Helper function to create curve which displays a Reuleaux polygons.
Parameters:
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 {@link JXG.Curve}.
Example:
var A = brd.create('point',[2,2]);
var B = brd.create('point',[0,1]);
var pol = brd.create('regularpolygon',[A,B,3], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});
var reuleauxTriangle = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol.vertices, 3),
{strokeWidth:6, strokeColor:'#d66d55', fillColor:'#ad5544', highlightFillColor:'#ad5544'});
rotation

rotpoint

point

phi

[board=point.board]
Computes the new position of a point which is rotated around a second point (called rotpoint) by the angle phi.
Parameters:
Returns:
Coordinates of the new position.
signedPolygon

p

[sort=true]
Determine the signed area of a nonintersecting polygon. Surveyor's Formula
Parameters:
Returns:
signedTriangle

p1

p2

p3
Signed triangle area of the three points given.
Parameters:

p1
JXG.Point  JXG.Coords  Array 
p2
JXG.Point  JXG.Coords  Array 
p3
JXG.Point  JXG.Coords  Array
Returns:
sortVertices

p
Sort list of points counter clockwise starting with the point with the lowest y coordinate.
Parameters:

p
ArrayAn array containing {@link JXG.Point}, {@link JXG.Coords}, and/or arrays.
Returns:
trueAngle

A

B

C
Calculates the angle (in degrees) defined by the three points A, B, C if you're going from A to C around B counterclockwise.
Parameters:

A
JXG.Point,ArrayPoint or [x,y] array

B
JXG.Point,ArrayPoint or [x,y] array

C
JXG.Point,ArrayPoint or [x,y] array
Returns:
The angle in degrees.
See also:
 #rad