# JSXGraph 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
- Axis
- Bisector
- Bisectorlines
- Circle
- Circumcenter
- Circumcircle
- CircumcircleArc
- Circumcirclesector
- Conic
- Curve
- Ellipse
- Functiongraph
- Glider
- Grid
- Hyperbola
- Image
- Incenter
- Incircle
- Integral
- Intersection
- Line
- Locus
- Midpoint
- Mirrorpoint
- Normal
- Orthogonalprojection
- OtherIntersection
- Parabola
- Parallel
- Parallelpoint
- Perpendicular
- Perpendicularpoint
- Point
- Polygon
- Reflection
- RegularPolygon
- Riemannsum
- Sector
- Segment
- Semicircle
- Slider
- Tangent
- Text
- Ticks
- Tracecurve

## Classes

- _global_
- JXG
- JXG.AbstractRenderer
- JXG.Board
- JXG.C
- JXG.CanvasRenderer
- JXG.Circle
- JXG.Complex
- JXG.Composition
- JXG.Coords
- JXG.Curve
- JXG.Dump
- JXG.GeometryElement
- JXG.GeonextParser
- JXG.Group
- JXG.Image
- JXG.JessieCode
- JXG.JSXGraph
- JXG.Line
- JXG.Math
- JXG.Math.Geometry
- JXG.Math.Numerics
- JXG.Math.Poly
- JXG.Math.Poly.Monomial
- JXG.Math.Poly.Polynomial
- JXG.Math.Poly.Ring
- JXG.Math.Statistics
- JXG.Math.Symbolic
- JXG.Point
- JXG.Polygon
- JXG.Server
- JXG.Server.modules
- JXG.SVGRenderer
- JXG.Text
- JXG.Ticks
- JXG.Turtle
- JXG.Util
- JXG.VMLRenderer

# 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, id, name, withLabel, layer) The Line class is a basic class for all kind of line objects, e.g.

Fields borrowed from class JXG.GeometryElement:
  addEvent, ancestors, baseElement, board, childElements, dash, descendants, draft, dump, elementClass, elType, eventHandlers, fillColor, fillOpacity, fixed, frozen, getAttribute, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, isDraggable, isReal, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, notExistingParents, numTraces, quadraticform, removeEvent, shadow, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, trace, traceAttributes, traces, transformations, type, visible, visProp, 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:
  addEvent, ancestors, baseElement, board, childElements, dash, descendants, draft, dump, elementClass, elType, eventHandlers, fillColor, fillOpacity, fixed, frozen, getAttribute, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, isDraggable, isReal, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, notExistingParents, numTraces, quadraticform, removeEvent, shadow, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, trace, traceAttributes, traces, transformations, type, visible, visProp, withLabel

Method Summary
Method Attributes | Method Name and Description
--- | ---
| addTicks(ticks) Adds ticks to this line.
| addTransform(transform) Add transformations to this line.
<private> | generatePolynomial(p) Used to generate a polynomial for a point p that lies on this line, i.e.
| getAngle() Determines the angle between the positive x axis and the line.
| getRise() Calculates the rise of the line.
| getSlope() Calculates the slope of the line.
| hasPoint(x, y) Checks whether (x,y) is near the line.
<private> | maxX() TODO circle?!? --michael private or public? --michael Treat the circle as parametric curve: t runs from 0 to 1
<private> | minX() TODO circle?!? --michael private or public? --michael Treat the circle as parametric curve: t runs from 0 to 1
| removeAllTicks() Removes all ticks from a line.
| removeTicks(tick) Removes ticks identified by parameter named tick from this line.
<private> | setLabelRelativeCoords(relCoords) Adjusts Label coords relative to Anchor.
| setPosition(method, x, y) TODO DESCRIPTION.
| setPositionDirectly(method, x, y, oldx, oldy) Sets x and y coordinate and calls the circle's update() method.
<private> | setStraight(straightFirst, straightLast) Determines whether the line is drawn beyond #point1 and #point2 and updates the line.
<private> | update() TODO description.
<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() TODO description.
| 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, animate, bounds, clearTrace, cloneToBackground, countChildren, createGradient, createLabel, draggable, getAttributes, getLabelAnchor, getName, getParents, getProperty, getTextAnchor, getType, hideElement, labelColor, noHighlight, normalize, off, on, prepareUpdate, remove, resolveShortcuts, setArrow, setAttribute, setDash, setLabelText, setProperty, showElement, triggerEventHandlers

Class Detail
JXG.Line(board, p1, p2, id, name, withLabel, layer)
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.
{String} id
  Unique identifier for this object. If null or an empty string is given, an unique id will be generated by Board
{String} name
  Not necessarily unique name. If null or an empty string is given, an unique name will be generated.
{boolean} withLabel
  construct label, yes/no
{integer} layer
  display layer [0-9]

See:
  JXG.Board#generateName

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 udpate system so your construction won't be updated properly.

{JXG.Point} point2
Endpoint of the line. Just like #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
{String} addTicks(ticks)
Adds ticks to this line. Ticks can be added to any kind of line: line, arrow, and axis.

Parameters:
{JXG.Ticks} ticks
  Reference to a ticks object which is describing the ticks (color, distance, how many, etc.).

Returns:
  Id of the ticks object.

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

Parameters:
{JXG.Transform|Array} transform
  Either one JXG.Transform or an array of JXG.Transforms.

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

<private> {array} generatePolynomial(p)
Used to generate a polynomial for a point p that lies on this line, i.e. p is collinear to #point1 and #point2.

Parameters:
{JXG.Point} p
  The point for that the polynomial is generated.

Returns:
  An array containing the generated polynomial.

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

Returns:
  {Number}

{float} getRise()
Calculates the rise of the line.

Returns:
  The rise of the line.

{float} getSlope()
Calculates the slope of the line.

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

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

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

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

<private> maxX()
TODO circle?!? --michael private or public? --michael Treat the circle as parametric curve: t runs from 0 to 1

<private> minX()
TODO circle?!? --michael private or public? --michael Treat the circle as parametric curve: t runs from 0 to 1

removeAllTicks()
Removes all ticks from a line.

removeTicks(tick)
Removes ticks identified by parameter named tick from this line.

Parameters:
{JXG.Ticks} tick
  Reference to tick object to remove.

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

Parameters:
relCoords

{JXG.Line} setPosition(method, x, y)
TODO DESCRIPTION.

Parameters:
{null} method
  ignored
{Number} x
{Number} y

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

setPositionDirectly(method, x, y, oldx, oldy)
Sets x and y coordinate and calls the circle's update() method.

Parameters:
{Number} method
  The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.
{Number} x
  x coordinate in screen/user units
{Number} y
  y coordinate in screen/user units
{Number} oldx
  previous x coordinate in screen/user units
{Number} oldy
  previous y coordinate in screen/user units

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

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

See:
  #straightFirst
  #straightLast

<private> update()
TODO description. maybe. already documented in geometryelement?

<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()
TODO description. already documented in geometryelement?

{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 #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 #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 Mon Apr 02 2012 17:54:08 GMT+0200 (MESZ)