# JSXGraph 1.7.0 Reference

## JavaScript must be enabled in order for you to use JSXGraph and JSXGraph reference. However, it seems JavaScript is either disabled or not supported by your browser.

Class Index | File Index

Elements

Classes

- _global_
- Angle
- Arc
- Arrow
- Arrowparallel
- Axis
- Bisector
- Bisectorlines
- Boxplot
- Button
- Cardinalspline
- Chart
- Checkbox
- Circle
- Circumcenter
- Circumcircle
- CircumcircleArc
- CircumcircleSector
- Comb
- Conic
- Curve
- Curve3D
- CurveDifference
- CurveIntersection
- CurveUnion
- Derivative
- Ellipse
- ForeignObject
- Functiongraph
- Functiongraph3D
- Glider
- Grid
- Group
- Hatch
- Hyperbola
- Image
- ImplicitCurve
- Incenter
- Incircle
- Inequality
- Input
- Integral
- Intersection
- JXG
- JXG.AbstractRenderer
- JXG.Board
- JXG.Board.infobox
- JXG.C
- JXG.CA
- JXG.CanvasRenderer
- JXG.Chart
- JXG.Circle
- JXG.Complex
- JXG.Composition
- JXG.Coords
- JXG.CoordsElement
- JXG.Curve
- JXG.Curve3D
- JXG.Dump
- JXG.EventEmitter
- JXG.Expect
- JXG.ForeignObject
- JXG.GeometryElement
- JXG.GeometryElement3D
- JXG.GeonextParser
- JXG.Group
- JXG.Image
- JXG.JessieCode
- JXG.JSXGraph
- JXG.Legend
- JXG.Line
- JXG.Line3D
- JXG.Math
- JXG.Math.BoxQuadtree
- JXG.Math.Clip
- JXG.Math.Extrapolate
- JXG.Math.Geometry
- JXG.Math.ImplicitPlot
- JXG.Math.IntervalArithmetic
- JXG.Math.Metapost
- JXG.Math.Nlp
- JXG.Math.Numerics
- JXG.Math.Plot
- JXG.Math.Poly
- JXG.Math.Poly.Monomial
- JXG.Math.Poly.Polynomial
- JXG.Math.Poly.Ring
- JXG.Math.ProbFuncs
- JXG.Math.Quadtree
- JXG.Math.Statistics
- JXG.Math.Symbolic
- JXG.NoRenderer
- JXG.Options
- JXG.Plane3D
- JXG.Point
- JXG.Point3D
- JXG.Polygon
- JXG.PrefixParser
- JXG.Server
- JXG.Server.modules
- JXG.Surface3D
- JXG.SVGRenderer
- JXG.Text
- JXG.Ticks
- JXG.Transformation
- JXG.Turtle
- JXG.Util
- JXG.Util.Base64
- JXG.Util.Unzip
- JXG.Util.UTF8
- JXG.View3D
- JXG.VMLRenderer
- JXG.XML
- Label
- Legend
- Line
- Line3D
- Locus
- MajorArc
- MajorSector
- Measurement
- Metapostspline
- Midpoint
- MinorArc
- MinorSector
- mirrorelement
- Mirrorpoint
- NonReflexAngle
- Normal
- Orthogonalprojection
- OtherIntersection
- Parabola
- Parallel
- Parallelogram
- Parallelpoint
- ParametricSurface3D
- Perpendicular
- PerpendicularPoint
- PerpendicularSegment
- Point
- Point3D
- PolarLine
- PolePoint
- Polygon
- PolygonalChain
- RadicalAxis
- Reflection
- ReflexAngle
- RegularPolygon
- Riemannsum
- Sector
- Segment
- Semicircle
- Slider
- Slopefield
- Slopetriangle
- Smartlabel
- Spline
- Stepfunction
- Tangent
- Tapemeasure
- Text
- Ticks
- Tracecurve
- Transformation
- Turtle
- Vectorfield
- Vectorfield3D
- View3D

# Class JXG.CoordsElement

JXG.GeometryElement
↳ JXG.CoordsElement

Creates a new coords element object. Do not use this constructor to create an element.
Defined in: coordselement.js.
Extends JXG.GeometryElement.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
<private> | JXG.CoordsElement(coordinates, isLabel) An element containing coords is the basic geometric element.

Fields borrowed from class JXG.GeometryElement:
  _org_type, _pos, ancestors, baseElement, board, childElements, dash, dashScale, descendants, draft, dragToTopOfLayer, dump, elementClass, elType, fillColor, fillOpacity, fixed, frozen, gradient, gradientAngle, gradientCX, gradientCY, gradientEndOffset, gradientFR, gradientFX, gradientFY, gradientR, gradientSecondColor, gradientSecondOpacity, gradientStartOffset, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, inherits, isDraggable, isLabel, isReal, lastDragTime, layer, lineCap, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, notExistingParents, numTraces, parents, precision, priv, quadraticform, rendNode, rotatable, scalable, shadow, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, tabindex, trace, traceAttributes, traces, transformations, transitionDuration, transitionProperties, type, viewport, visible, visProp, visPropCalc, withLabel

Field Summary
Field Attributes | Field Name and Description
--- | ---
<private> | coords Coordinates of the element.
<private> | groups Stores the groups of this element in an array of Group.
<private> | isConstrained True if there the method this.updateConstraint() has been set.
| needsUpdateFromParent A JXG.CoordsElement#updateGlider call is usually followed by a general JXG.Board#update which calls JXG.CoordsElement#updateGliderFromParent.
<private> | onPolygon Determines whether the element slides on a polygon if point is a glider.
<private> | position Relative position on a slide element (line, circle, curve) if element is a glider on this element.
| slideObject When used as a glider this member stores the object, where to glide on.
| slideObjects List of elements the element is bound to, i.e.

Fields borrowed from class JXG.GeometryElement:
  _org_type, _pos, ancestors, baseElement, board, childElements, dash, dashScale, descendants, draft, dragToTopOfLayer, dump, elementClass, elType, fillColor, fillOpacity, fixed, frozen, gradient, gradientAngle, gradientCX, gradientCY, gradientEndOffset, gradientFR, gradientFX, gradientFY, gradientR, gradientSecondColor, gradientSecondOpacity, gradientStartOffset, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, inherits, isDraggable, isLabel, isReal, lastDragTime, layer, lineCap, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, notExistingParents, numTraces, parents, precision, priv, quadraticform, rendNode, rotatable, scalable, shadow, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, tabindex, trace, traceAttributes, traces, transformations, transitionDuration, transitionProperties, type, viewport, visible, visProp, visPropCalc, withLabel

Method Summary
Method Attributes | Method Name and Description
--- | ---
<private> | _anim(direction, stepCount) Animates a glider.
<private> | addAnchor(coordinates, isLabel) In case there is an attribute "anchor", the element is bound to this anchor element.
| addConstraint(terms) Convert the point to CAS point and call update().
| addTransform(el, transform) Add transformations to this element.
| Coords(digits, withZ) Getter method for coordinates x, y and (optional) z.
<static> | JXG.CoordsElement.create(Callback, board, coords, attr, arg1, arg2) Generic method to create point, text or image.
| Dist(point2) Getter method for the distance to a second point, this is required for CAS-elements.
<private> | findClosestSnapValue(pos) Find the closest entry in snapValues that is within snapValueDistance of pos.
| free() Converts a calculated element into a free element, i.e.
| handleAttractors() A point can change its type from free point to glider and vice versa.
| handleSnapToPoints(force) Let a point snap to the nearest point in distance of JXG.Point#attractorDistance.
| makeGlider(slide) Convert the point to glider and update the construction.
| moveAlong(path, time, options) Starts an animation which moves the point along a given path in given time.
| moveTo(where, time, options) Starts an animated point movement towards the given coordinates `where`.
| popSlideObject() Remove the last slideObject.
| setGliderPosition(x) Sets the position of a glider relative to the defining elements of the JXG.Point#slideObject.
| setPosition(method, coords) Sets coordinates and calls the point's update() method.
| setPositionByTransform(method, tv) Translates the point by `tv = (x, y)`.
| setPositionDirectly(method, coords) Sets coordinates and calls the point's update() method.
| snapToGrid(force) Alias for JXG.Element#handleSnapToGrid
| snapToPoints(force) Alias for JXG.CoordsElement#handleSnapToPoints.
<private> | updateConstraint() Dummy function for unconstrained points or gliders.
<private> | updateCoords(fromParent) Updates the coordinates of the element.
<private> | updateGlider() Update of glider in case of dragging the glider or setting the postion of the glider.
<private> | updateGliderFromParent() Update of a glider in case a parent element has been updated.
| updateTransform(fromParent) Applies the transformations of the element.
| visit(where, time, options) Starts an animated point movement towards the given coordinates `where`.
| X() Getter method for x, this is used by for CAS-points to access point coordinates.
<private> | XEval() New evaluation of the function term.
| Y() Getter method for y, this is used by CAS-points to access point coordinates.
<private> | YEval() New evaluation of the function term.
| Z() Getter method for z, this is used by CAS-points to access point coordinates.
<private> | ZEval() New evaluation of the function term.

Methods borrowed from class JXG.GeometryElement:
  _set, addChild, addDescendants, addParents, addParentsFromJCFunctions, addRotation, addTicks, animate, bounds, clearTrace, cloneToBackground, countChildren, createGradient, createLabel, draggable, formatNumberLocale, fullUpdate, generatePolynomial, getAttribute, getAttributes, getLabelAnchor, getName, getParents, getProperty, getSnapSizes, getTextAnchor, getType, handleSnapToGrid, hasPoint, hide, hideElement, noHighlight, normalize, prepareUpdate, remove, removeAllTicks, removeChild, removeDescendants, removeTicks, resolveShortcuts, setArrow, setAttribute, setDash, setDisplayRendNode, setLabel, setLabelText, setName, setParents, setProperty, show, showElement, update, updateRenderer, updateVisibility, useLocale

Events borrowed from class JXG.GeometryElement:
  attribute, attribute:key, down, drag, keydrag, mousedown, mousedrag, mousemove, mouseout, mouseover, mouseup, move, out, over, pendown, pendrag, penup, touchdown, touchdrag, touchup, up

Class Detail
<private> JXG.CoordsElement(coordinates, isLabel)
An element containing coords is the basic geometric element. Based on points lines and circles can be constructed which can be intersected which in turn are points again which can be used to construct new lines, circles, polygons, etc. This class holds methods for all kind of coordinate elements like points, texts and images.

Parameters:
{Array} coordinates
  An array with the affine user coordinates of the point. JXG.Options#elements, and - optionally - a name and an id.
isLabel

Field Detail
<private> {JXG.Coords} coords
Coordinates of the element.

<private> {Array} groups
Stores the groups of this element in an array of Group.

See:
  JXG.Group

<private> {Boolean} isConstrained
True if there the method this.updateConstraint() has been set. It is probably different from the prototype function() {return this;}. Used in updateCoords fo glider elements.

See:
  JXG.CoordsElement#updateCoords

{Boolean} needsUpdateFromParent
A JXG.CoordsElement#updateGlider call is usually followed by a general JXG.Board#update which calls JXG.CoordsElement#updateGliderFromParent. To prevent double updates, JXG.CoordsElement#needsUpdateFromParent is set to false in updateGlider() and reset to true in the following call to JXG.CoordsElement#updateGliderFromParent

<private> {Boolean} onPolygon
Determines whether the element slides on a polygon if point is a glider.

Default Value:
  false

<private> {Number} position
Relative position on a slide element (line, circle, curve) if element is a glider on this element.

{JXG.GeometryElement} slideObject
When used as a glider this member stores the object, where to glide on. To set the object to glide on use the method JXG.Point#makeGlider and DO NOT set this property directly as it will break the dependency tree.

slideObjects
List of elements the element is bound to, i.e. the element glides on. Only the last entry is active. Use JXG.Point#popSlideObject to remove the currently active slideObject.
Method Detail
<private> {JXG.CoordsElement} _anim(direction, stepCount)
Animates a glider. Is called by the browser after startAnimation is called.

Parameters:
{Number} direction
  The direction the glider is animated.
{Number} stepCount
  The number of steps in which the parent element is divided. Must be at least 1.

Returns:
  {JXG.CoordsElement} Reference to itself.

See:
  #startAnimation
  #stopAnimation

<private> addAnchor(coordinates, isLabel)
In case there is an attribute "anchor", the element is bound to this anchor element. This is handled with this.relativeCoords. If the element is a label relativeCoords are given in scrCoords, otherwise in usrCoords.

Parameters:
coordinates
isLabel

addConstraint(terms)
Convert the point to CAS point and call update().

Parameters:
{Array} terms
  [[zterm], xterm, yterm] defining terms for the z, x and y coordinate. The z-coordinate is optional and it is used for homogeneous coordinates. The coordinates may be either
  - a JavaScript function,
  - a string containing GEONExT syntax. This string will be converted into a JavaScript function here,
  - a Number
  - a pointer to a slider object. This will be converted into a call of the Value()-method of this slider.

See:
  JXG.GeonextParser#geonext2JS

{JXG.CoordsElement} addTransform(el, transform)
Add transformations to this element.

Parameters:
{JXG.GeometryElement} el
{JXG.Transformation|Array} transform
  Either one JXG.Transformation or an array of JXG.Transformations.

Returns:
  {JXG.CoordsElement} Reference to itself.

{String} Coords(digits, withZ)
Getter method for coordinates x, y and (optional) z.

Parameters:
{Number|String} digits Optional, Default: 'auto'
  Truncating rule for the digits in the infobox.
  - 'auto': done automatically by JXG.autoDigits()
  - 'none': no truncation
  - number: truncate after "number digits" with JXG.toFixed()
{Boolean} withZ Optional, Default: false
  If set to true the return value will be `(x | y | z)` instead of `(x, y)`.

Returns:
  {String} User coordinates of point.

<static> JXG.CoordsElement.create(Callback, board, coords, attr, arg1, arg2)
Generic method to create point, text or image. Determines the type of the construction, i.e. free, or constrained by function, transformation or of glider type.

Parameters:
Callback
board
coords
attr
arg1
arg2

{Number} Dist(point2)
Getter method for the distance to a second point, this is required for CAS-elements. Here, function inlining seems to be worthwile (for plotting).

Parameters:
{JXG.Point} point2
  The point to which the distance shall be calculated.

Returns:
  {Number} Distance in user coordinate to the given point

<private> {Number} findClosestSnapValue(pos)
Find the closest entry in snapValues that is within snapValueDistance of pos.

Parameters:
{Number} pos
  Value for which snapping is calculated.

Returns:
  {Number} Index of the value to snap to, or null.

free()
Converts a calculated element into a free element, i.e. it will delete all ancestors and transformations and, if the element is currently a glider, will remove the slideObject reference.

{JXG.Point} handleAttractors()
A point can change its type from free point to glider and vice versa. If it is given an array of attractor elements (attribute attractors) and the attribute attractorDistance then the point will be made a glider if it less than attractorDistance apart from one of its attractor elements. If attractorDistance is equal to zero, the point stays in its current form.

Returns:
  {JXG.Point} Reference to this element

{JXG.Point} handleSnapToPoints(force)
Let a point snap to the nearest point in distance of JXG.Point#attractorDistance. The function uses the coords object of the point as its actual position.

Parameters:
{Boolean} force
  force snapping independent of what the snaptogrid attribute says

Returns:
  {JXG.Point} Reference to this element

makeGlider(slide)
Convert the point to glider and update the construction. To move the point visual onto the glider, a call of board update is necessary.

Parameters:
{String|Object} slide
  The object the point will be bound to.

{JXG.CoordsElement} moveAlong(path, time, options)
Starts an animation which moves the point along a given path in given time.

Parameters:
{Array|function} path
  The path the point is moved on. This can be either an array of arrays or containing x and y values of the points of the path, or an array of points, or a function taking the amount of elapsed time since the animation has started and returns an array containing a x and a y value or NaN. In case of NaN the animation stops.
{Number} time
  The time in milliseconds in which to finish the animation
{Object} options Optional
  Optional settings for the animation.
{function} options.callback Optional
  A function that is called as soon as the animation is finished.
{Boolean} options.interpolate Optional, Default: true
  If `path` is an array moveAlong() will interpolate the path using JXG.Math.Numerics.Neville. Set this flag to false if you don't want to use interpolation.

Returns:
  {JXG.CoordsElement} Reference to itself.

See:
  JXG.CoordsElement#moveAlong
  JXG.CoordsElement#moveTo
  JXG.GeometryElement#animate

{JXG.CoordsElement} moveTo(where, time, options)
Starts an animated point movement towards the given coordinates `where`. The animation is done after `time` milliseconds. If the second parameter is not given or is equal to 0, setPosition() is called, see #setPosition, i.e. the coordinates are changed without animation.

Parameters:
{Array} where
  Array containing the x and y coordinate of the target location.
{Number} time Optional
  Number of milliseconds the animation should last.
{Object} options Optional
  Optional settings for the animation
{function} options.callback Optional
  A function that is called as soon as the animation is finished.
{String} options.effect Optional, Default: '<>'
  animation effects like speed fade in and out. possible values are '<>' for speed increase on start and slow down at the end (default) and '--' for constant speed during the whole animation.

Returns:
  {JXG.CoordsElement} Reference to itself.

See:
  JXG.CoordsElement#moveAlong
  JXG.CoordsElement#visit
  JXG.GeometryElement#animate

popSlideObject()
Remove the last slideObject. If there are more than one elements the point is bound to, the second last element is the new active slideObject.

{JXG.Point} setGliderPosition(x)
Sets the position of a glider relative to the defining elements of the JXG.Point#slideObject.

Parameters:
{Number} x

Returns:
  {JXG.Point} Reference to the point element.

{JXG.Point} setPosition(method, coords)
Sets coordinates and calls the point's update() method.

Parameters:
{Number} method
  The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.
{Array} coords
  coordinates in screen/user units

Returns:
  {JXG.Point}

{JXG.Point} setPositionByTransform(method, tv)
Translates the point by `tv = (x, y)`.

Parameters:
{Number} method
  The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.
{Array} tv
  (x, y)

Returns:
  {JXG.Point}

{JXG.Point} setPositionDirectly(method, coords)
Sets coordinates and calls the point's update() method.

Parameters:
{Number} method
  The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.
{Array} coords
  coordinates `([z], x, y)` in screen/user units

Returns:
  {JXG.Point} this element

{JXG.CoordsElement} snapToGrid(force)
Alias for JXG.Element#handleSnapToGrid

Parameters:
{Boolean} force
  force snapping independent of what the snaptogrid attribute says

Returns:
  {JXG.CoordsElement} Reference to this element

{JXG.Point} snapToPoints(force)
Alias for JXG.CoordsElement#handleSnapToPoints.

Parameters:
{Boolean} force
  force snapping independent of what the snaptogrid attribute says

Returns:
  {JXG.Point} Reference to this element

<private> updateConstraint()
Dummy function for unconstrained points or gliders.

<private> updateCoords(fromParent)
Updates the coordinates of the element.

Parameters:
fromParent

<private> updateGlider()
Update of glider in case of dragging the glider or setting the postion of the glider. The relative position of the glider has to be updated. In case of a glider on a line: If the second point is an ideal point, then -1 < this.position < 1, this.position==+/-1 equals point2, this.position==0 equals point1 If the first point is an ideal point, then 0 < this.position < 2 this.position==0 or 2 equals point1, this.position==1 equals point2

<private> updateGliderFromParent()
Update of a glider in case a parent element has been updated. That means the relative position of the glider stays the same.

{JXG.CoordsElement} updateTransform(fromParent)
Applies the transformations of the element. This method applies to text and images. Point transformations are handled differently.

Parameters:
{Boolean} fromParent
  True if the drag comes from a child element. Unused.

Returns:
  {JXG.CoordsElement} Reference to itself.

{JXG.CoordsElement} visit(where, time, options)
Starts an animated point movement towards the given coordinates `where`. After arriving at `where` the point moves back to where it started. The animation is done after `time` milliseconds.

Parameters:
{Array} where
  Array containing the x and y coordinate of the target location.
{Number} time
  Number of milliseconds the animation should last.
{Object} options Optional
  Optional settings for the animation
{function} options.callback Optional
  A function that is called as soon as the animation is finished.
{String} options.effect Optional, Default: '<>'
  animation effects like speed fade in and out. possible values are '<>' for speed increase on start and slow down at the end (default) and '--' for constant speed during the whole animation.
{Number} options.repeat Optional, Default: 1
  How often this animation should be repeated.

Returns:
  {JXG.CoordsElement} Reference to itself.

See:
  JXG.CoordsElement#moveAlong
  JXG.CoordsElement#moveTo
  JXG.GeometryElement#animate

{Number} X()
Getter method for x, this is used by for CAS-points to access point coordinates.

Returns:
  {Number} User coordinate of point in x direction.

<private> {Number} XEval()
New evaluation of the function term. This is required for CAS-points: Their XTerm() method is overwritten in JXG.CoordsElement#addConstraint.

Returns:
  {Number} User coordinate of point in x direction.

{Number} Y()
Getter method for y, this is used by CAS-points to access point coordinates.

Returns:
  {Number} User coordinate of point in y direction.

<private> {Number} YEval()
New evaluation of the function term. This is required for CAS-points: Their YTerm() method is overwritten in JXG.CoordsElement#addConstraint.

Returns:
  {Number} User coordinate of point in y direction.

{Number} Z()
Getter method for z, this is used by CAS-points to access point coordinates.

Returns:
  {Number} User coordinate of point in z direction.

<private> {Number} ZEval()
New evaluation of the function term. This is required for CAS-points: Their ZTerm() method is overwritten in JXG.CoordsElement#addConstraint.

Returns:
  {Number} User coordinate of point in z direction.

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 15 2024 17:48:02 GMT+0000 (Coordinated Universal Time)