JXG.Line

Class

Creates a new basic line object. Do not use this constructor to create a line. 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. Use JXG.Board#create with type Line, Arrow, or Axis instead.

Attributes

Own

none

Inherited

Members

Own

defaultTicks : JXG.Ticks

Description

Reference of the ticks created automatically when constructing an axis.

Type
JXG.Ticks
See
Source
base/line.js, line 99

(private) parentPolygon : JXG.Polygon

Description

If the line is the border of a polygon, the polygon object is stored, otherwise null.

Type
JXG.Polygon
Default Value
null
Source
base/line.js, line 107

point1 : JXG.Point

Description

Starting point 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.

Type
JXG.Point
Source
base/line.js, line 78

point2 : JXG.Point

Description

End point of the line. Just like JXG.Line.point1 you shouldn't write this field directly.

Type
JXG.Point
Source
base/line.js, line 84

ticks : Array

Description

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

Type
Array
See
Source
base/line.js, line 92

Inherited

Methods

Own

Direction() → {Array}

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

of length 2.

Type
Array

Details

Source
base/line.js, line 600

Ft(t) → {Array}

Return the homogeneous coordinates of the line treated as curve at t - including all transformations applied to the curve.

Parameters

Name Type Description
t Number

A number

Returns

[Z(t), X(t), Y(t)]

Type
Array

Details

See
Source
base/line.js, line 1081

L() → {Number}

The distance between the two points defining the line.

Returns

Type
Number

Details

Source
base/line.js, line 1097

Slope() → {Number}

Calculates the slope of the line.

Returns

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

Type
Number

Details

Source
base/line.js, line 537

X(t) → {Number}

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

Name Type Description
t Number

Parameter running from 0 to 1.

Returns

X(t) x-coordinate of the line treated as parametric curve.

Type
Number

Details

Source
base/line.js, line 983

Y(t) → {Number}

Treat the line as parametric curve in homogeneous coordinates. See JXG.Line#X for a detailed description.

Parameters

Name Type Description
t Number

Parameter running from 0 to 1.

Returns

Y(t) y-coordinate of the line treated as parametric curve.

Type
Number

Details

See
Source
base/line.js, line 1019

Z(t) → {Number}

Treat the line as parametric curve in homogeneous coordinates. See JXG.Line#X for a detailed description.

Parameters

Name Type Description
t Number

Parameter running from 0 to 1.

Returns

Z(t) z-coordinate of the line treated as parametric curve.

Type
Number

Details

See
Source
base/line.js, line 1056

addTransform(transform) → {JXG.Line}

Add transformations to this line.

Parameters

Name Type Description
transform JXG.Transformation | Array

Either one JXG.Transformation or an array of JXG.Transformations.

Returns

Reference to this line object.

Type
JXG.Line

Details

Overrides
JXG.GeometryElement#addTransform
Source
base/line.js, line 852

getAngle(unitopt) → {Number}

Determines the angle between the positive x axis and the line.

Parameters

Name Type Attributes Default Description
unit String <optional>
'radians'

Unit of the returned values. Possible units are

  • 'radians' (default): angle value in radians
  • 'degrees': angle value in degrees
  • 'semicircle': angle value in radians as a multiple of π, e.g. if the angle is 1.5π, 1.5 will be returned.
  • 'circle': angle value in radians as a multiple of 2π

Returns

Type
Number

Details

Source
base/line.js, line 566

getRise() → {Number}

Calculates the y intersect of the line.

Returns

The y intersect.

Type
Number

Details

Source
base/line.js, line 525

getSlope() → {Number}

Alias for line.Slope

Returns

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

Type
Number

Details

Deprecated
Yes
See
Source
base/line.js, line 551

hasPoint(x, y) → {Boolean}

Checks whether (x,y) is near the line.

Parameters

Name Type Description
x Number

Coordinate in x direction, screen coordinates.

y Number

Coordinate in y direction, screen coordinates.

Returns

True if (x,y) is near the line, False otherwise.

Type
Boolean

Details

Overrides
JXG.GeometryElement#hasPoint
Source
base/line.js, line 170

isHorizontal() → {Boolean}

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

Returns

Type
Boolean

Details

Source
base/line.js, line 633

isVertical() → {Boolean}

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

Returns

Type
Boolean

Details

Source
base/line.js, line 623

(private) maxX()

Treat the element as parametric curve

Details

Source
base/line.js, line 1131

(private) minX()

Treat the element as a parametric curve

Details

Source
base/line.js, line 1123

setFixedLength(l) → {JXG.Line}

Set a new fixed length, then update the board.

Parameters

Name Type Description
l String | Number | function

A string, function or number describing the new length.

Returns

Reference to this line

Type
JXG.Line

Details

Source
base/line.js, line 1106

(private) setLabelRelativeCoords()

Adjusts Label coords relative to Anchor. DESCRIPTION

Details

Source
base/line.js, line 673

(private) setStraight(straightFirst, straightLast)

Determines whether the line is drawn beyond JXG.Line#point1 and JXG.Line#point2 and updates the line.

Parameters

Name Type Description
straightFirst Boolean

True if the Line shall be drawn beyond JXG.Line#point1, false otherwise.

straightLast Boolean

True if the Line shall be drawn beyond JXG.Line#point2, false otherwise.

Details

See
Source
base/line.js, line 649

(private) updateRenderer()

Uses the boards renderer to update the line.

Details

Overrides
JXG.GeometryElement#updateRenderer
Source
base/line.js, line 433

(private) updateSegmentFixedLength()

Update segments with fixed length and at least one movable point.

Details

Source
base/line.js, line 322

(private) updateStdform()

Updates the stdform derived from the parent point positions.

Details

Source
base/line.js, line 415

Inherited

Events

Own

none

Inherited

Parameters

Name Type Description
board String | JXG.Board

The board the new line is drawn on.

p1 Point

Startpoint of the line.

p2 Point

Endpoint of the line.

attributes Object

Javascript object containing attributes like name, id and colors.

Details

Source
base/line.js, line 70

Extends