# JSXGraph 1.11.1 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

- Angle
- Arc
- Arrow
- Arrowparallel
- Axes3D
- Axis
- Axis3D
- Bisector
- Bisectorlines
- Boxplot
- Button
- Cardinalspline
- Chart
- Checkbox
- Circle
- Circle3D
- Circumcenter
- Circumcircle
- CircumcircleArc
- CircumcircleSector
- Comb
- Conic
- Curve
- Curve3D
- CurveDifference
- CurveIntersection
- CurveUnion
- Derivative
- Ellipse
- Face3D
- ForeignObject
- Functiongraph
- Functiongraph3D
- Glider
- Grid
- Group
- Hatch
- Hyperbola
- Image
- ImplicitCurve
- Incenter
- Incircle
- Inequality
- Input
- Integral
- Intersection
- IntersectionCircle3D
- IntersectionLine3D
- Label
- Legend
- Line
- Line3D
- MajorArc
- MajorSector
- Measurement
- Mesh3D
- Metapostspline
- Midpoint
- MinorArc
- MinorSector
- MirrorElement
- MirrorPoint
- NonReflexAngle
- Normal
- Orthogonalprojection
- OtherIntersection
- Parabola
- Parallel
- Parallelogram
- Parallelpoint
- ParametricSurface3D
- Perpendicular
- PerpendicularPoint
- PerpendicularSegment
- Plane3D
- Point
- Point3D
- PolarLine
- PolePoint
- Polygon
- Polygon3D
- PolygonalChain
- Polyhedron3D
- RadicalAxis
- Reflection
- ReflexAngle
- RegularPolygon
- Riemannsum
- Sector
- Segment
- Semicircle
- Slider
- Slopefield
- Slopetriangle
- Smartlabel
- Sphere3D
- Spline
- Stepfunction
- Tangent
- TangentTo
- Tapemeasure
- Text
- Text3D
- Ticks
- Ticks3D
- Tracecurve
- Transformation
- Transformation3D
- Turtle
- Vectorfield
- Vectorfield3D
- View3D

Classes

- _global_
- JXG
- JXG.AbstractRenderer
- JXG.Board
- JXG.Board.infobox
- JXG.C
- JXG.CA
- JXG.CanvasRenderer
- JXG.Chart
- JXG.Circle
- JXG.Circle3D
- JXG.Complex
- JXG.Composition
- JXG.Coords
- JXG.CoordsElement
- JXG.Curve
- JXG.Curve3D
- JXG.Dump
- JXG.EventEmitter
- JXG.Expect
- JXG.Face3D
- 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.NoRenderer
- JXG.Options
- JXG.Plane3D
- JXG.Point
- JXG.Point3D
- JXG.Polygon
- JXG.Polygon3D
- JXG.PrefixParser
- JXG.Sphere3D
- JXG.Surface3D
- JXG.SVGRenderer
- JXG.Text
- JXG.Text3D
- JXG.Ticks
- JXG.Transformation
- JXG.Turtle
- JXG.Util
- JXG.Util.Base64
- JXG.Util.Unzip
- JXG.Util.UTF8
- JXG.View3D
- JXG.VMLRenderer
- JXG.XML

# Class JXG.Line

JXG.GeometryElement
↳ JXG.Line

Creates a new basic line object. Do not use this constructor to create a line. Use JXG.Board#create with type Line, Arrow, or Axis instead.
Defined in: line.js.
Extends JXG.GeometryElement.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| JXG.Line(board, p1, p2, attributes) The Line class is a basic class for all kind of line objects, e.g.

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

Field Summary
Field Attributes | Field Name and Description
--- | ---
| defaultTicks Reference of the ticks created automatically when constructing an axis.
<private> | parentPolygon If the line is the border of a polygon, the polygon object is stored, otherwise null.
| point1 Startpoint of the line.
| point2 Endpoint of the line.
| ticks Array of ticks storing all the ticks on this line.

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

Method Summary
Method Attributes | Method Name and Description
--- | ---
| addTransform(transform) Add transformations to this line.
| Direction() Returns the direction vector of the line.
| getAngle() Determines the angle between the positive x axis and the line.
| getRise() Calculates the y intersect of the line.
| getSlope() Alias for line.Slope
| hasPoint(x, y) Checks whether (x,y) is near the line.
| isHorizontal() Returns true, if the line is horizontal (if the y coordinate of the direction vector is 0).
| isVertical() Returns true, if the line is vertical (if the x coordinate of the direction vector is 0).
| L() The distance between the two points defining the line.
<private> | maxX() Treat the element as parametric curve
<private> | minX() Treat the element as a parametric curve
| setFixedLength(l) Set a new fixed length, then update the board.
<private> | setLabelRelativeCoords(relCoords) Adjusts Label coords relative to Anchor.
<private> | setStraight(straightFirst, straightLast) Determines whether the line is drawn beyond JXG.Line#point1 and JXG.Line#point2 and updates the line.
| Slope() Calculates the slope of the line.
<private> | updateRenderer() Uses the boards renderer to update the line.
<private> | updateSegmentFixedLength() Update segments with fixed length and at least one movable point.
<private> | updateStdform() Updates the stdform derived from the parent point positions.
| X(t) Treat the line as parametric curve in homogeneous coordinates, where the parameter t runs from 0 to 1.
| Y(t) Treat the line as parametric curve in homogeneous coordinates.
| Z(t) Treat the line as parametric curve in homogeneous coordinates.

Methods borrowed from class JXG.GeometryElement:
  _set, addChild, addDescendants, addParents, addParentsFromJCFunctions, addRotation, addTicks, animate, bounds, clearTrace, cloneToBackground, countChildren, createGradient, createLabel, draggable, eval, evalVisProp, formatNumberLocale, fullUpdate, generatePolynomial, getAttribute, getAttributes, getLabelAnchor, getName, getParents, getProperty, getSnapSizes, getTextAnchor, getType, handleSnapToGrid, hide, hideElement, noHighlight, normalize, prepareUpdate, remove, removeAllTicks, removeChild, removeDescendants, removeTicks, resolveShortcuts, setArrow, setAttribute, setDash, setDisplayRendNode, setLabel, setLabelText, setName, setParents, setPosition, setPositionDirectly, setProperty, show, showElement, snapToPoints, update, 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
JXG.Line(board, p1, p2, attributes)
The Line class is a basic class for all kind of line objects, e.g. line, arrow, and axis. It is usually defined by two points and can be intersected with some other geometry elements.

Parameters:
{String|JXG.Board} board
  The board the new line is drawn on.
{Point} p1
  Startpoint of the line.
{Point} p2
  Endpoint of the line.
{Object} attributes
  Javascript object containing attributes like name, id and colors.

Field Detail
{JXG.Ticks} defaultTicks
Reference of the ticks created automatically when constructing an axis.

See:
  JXG.Ticks

<private> {JXG.Polygon} parentPolygon
If the line is the border of a polygon, the polygon object is stored, otherwise null.

Default Value:
  null

{JXG.Point} point1
Startpoint of the line. You really should not set this field directly as it may break JSXGraph's update system so your construction won't be updated properly.

{JXG.Point} point2
Endpoint of the line. Just like JXG.Line.point1 you shouldn't write this field directly.

{Array} ticks
Array of ticks storing all the ticks on this line. Do not set this field directly and use JXG.Line#addTicks and JXG.Line#removeTicks to add and remove ticks to and from the line.

See:
  JXG.Ticks

Method Detail
{JXG.Line} addTransform(transform)
Add transformations to this line.

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

Returns:
  {JXG.Line} Reference to this line object.

{Array} Direction()
Returns the direction vector of the line. This is an array of length two containing the direction vector as [x, y]. It is defined as
- the difference of the x- and y-coordinate of the second and first point, in case both points are finite or both points are infinite.
- [x, y] coordinates of point2, in case only point2 is infinite.
- [-x, -y] coordinates of point1, in case only point1 is infinite.

Returns:
  {Array} of length 2.

{Number} getAngle()
Determines the angle between the positive x axis and the line.

Returns:
  {Number}

{Number} getRise()
Calculates the y intersect of the line.

Returns:
  {Number} The y intersect.

{Number} getSlope()
Alias for line.Slope

Returns:
  {Number} The slope of the line or Infinity if the line is parallel to the y-axis.

See:
  Line#Slope

{Boolean} hasPoint(x, y)
Checks whether (x,y) is near the line.

Parameters:
{Number} x
  Coordinate in x direction, screen coordinates.
{Number} y
  Coordinate in y direction, screen coordinates.

Returns:
  {Boolean} True if (x,y) is near the line, False otherwise.

{Boolean} isHorizontal()
Returns true, if the line is horizontal (if the y coordinate of the direction vector is 0).

Returns:
  {Boolean}

{Boolean} isVertical()
Returns true, if the line is vertical (if the x coordinate of the direction vector is 0).

Returns:
  {Boolean}

{Number} L()
The distance between the two points defining the line.

Returns:
  {Number}

<private> maxX()
Treat the element as parametric curve

<private> minX()
Treat the element as a parametric curve

{JXG.Line} setFixedLength(l)
Set a new fixed length, then update the board.

Parameters:
{String|Number|function} l
  A string, function or number describing the new length.

Returns:
  {JXG.Line} Reference to this line

<private> setLabelRelativeCoords(relCoords)
Adjusts Label coords relative to Anchor. DESCRIPTION

Parameters:
relCoords

<private> setStraight(straightFirst, straightLast)
Determines whether the line is drawn beyond JXG.Line#point1 and JXG.Line#point2 and updates the line.

Parameters:
{Boolean} straightFirst
  True if the Line shall be drawn beyond JXG.Line#point1, false otherwise.
{Boolean} straightLast
  True if the Line shall be drawn beyond JXG.Line#point2, false otherwise.

See:
  Line#straightFirst
  Line#straightLast

{Number} Slope()
Calculates the slope of the line.

Returns:
  {Number} The slope of the line or Infinity if the line is parallel to the y-axis.

<private> updateRenderer()
Uses the boards renderer to update the line.

<private> updateSegmentFixedLength()
Update segments with fixed length and at least one movable point.

<private> updateStdform()
Updates the stdform derived from the parent point positions.

{Number} X(t)
Treat the line as parametric curve in homogeneous coordinates, where the parameter t runs from 0 to 1. First we transform the interval [0,1] to [-1,1]. If the line has homogeneous coordinates [c, a, b] = stdform[] then the direction of the line is [b, -a]. Now, we take one finite point that defines the line, i.e. we take either point1 or point2 (in case the line is not the ideal line). Let the coordinates of that point be [z, x, y]. Then, the curve runs linearly from [0, b, -a] (t=-1) to [z, x, y] (t=0) and [z, x, y] (t=0) to [0, -b, a] (t=1)

Parameters:
{Number} t
  Parameter running from 0 to 1.

Returns:
  {Number} X(t) x-coordinate of the line treated as parametric curve.

{Number} Y(t)
Treat the line as parametric curve in homogeneous coordinates. See JXG.Line#X for a detailed description.

Parameters:
{Number} t
  Parameter running from 0 to 1.

Returns:
  {Number} Y(t) y-coordinate of the line treated as parametric curve.

{Number} Z(t)
Treat the line as parametric curve in homogeneous coordinates. See JXG.Line#X for a detailed description.

Parameters:
{Number} t
  Parameter running from 0 to 1.

Returns:
  {Number} Z(t) z-coordinate of the line treated as parametric curve.

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Apr 04 2025 09:22:41 GMT+0200 (Mitteleuropäische Sommerzeit)