Line3D

Element

A line in 3D is given by two points, or one point and a direction vector.

A line in 3D is given by two points, or one point and a direction vector. That is, there are the following two possibilities to create a Line3D object:

  • The 3D line is defined by two 3D points (Point3D): The points can be either existing points or coordinate arrays of the form [x, y, z].
  • The 3D line is defined by a point (or coordinate array [x, y, z]) a direction given as array [x, y, z] and an optional range given as array [s, e]. The default value for the range is [-Infinity, Infinity].

All numbers can also be provided as functions returning a number. The case [point, array] is ambiguous, it is not clear if array contains the coordinates of a point or of a direction. In that case, array is interpreted as the coordinate array of a point, i.e. the line is defined by two points.

Usage (signatures)
board.create('line3d', [point1, point2]);

First and second defining point of the line. The attributes Line3D#straightFirst and Line3D#straightLast control if the line is displayed as segment, ray or infinite line.

Parameters
Name Type Description
point1 Point3DLike
point2 Point3DLike
Example
var view = board.create(
     'view3d',
     [[-6, -3], [8, 8],
     [[-3, 3], [-3, 3], [-3, 3]]],
     {
         depthOrder: {
             enabled: true
         },
         projection: 'central',
         xPlaneRear: {fillOpacity: 0.2},
         yPlaneRear: {fillOpacity: 0.2},
         zPlaneRear: {fillOpacity: 0.2}
     }
 );

 var A = view.create('point3d', [0, 0, 0], {size: 2});
 var B = view.create('point3d', [2, 1, 1], {size: 2});
 var C = view.create('point3d', [-2.5, 2.5, 1.5], {size: 2});

 // Draggable line by two points
 var line1 = view.create('line3d', [A, B], {
     fixed: false,
     straightFirst: true,
     straightLast: true,
     dash: 2
 });

 // Line by point, direction, and range
 var line2 = view.create('line3d', [C, [1, 0, 0], [-1, Infinity]], {
     strokeColor: 'blue'
 });

 // Line by point and array
 var line3 = view.create('line3d', [C, [-2.5, -1, 1.5]], {
     point2: { visible: true},
     strokeColor: 'red'
 });

board.create('line3d', [point, direction, range]);
Parameters
Name Type Description
point Point3DLike
direction Line3D | Array
range Array | function

Array of length 2, elements can also be functions. Use [-Infinity, Infinity] for infinite lines.

Examples
var bound = [-5, 5];
 var view = board.create('view3d',
     [[-6, -3], [8, 8],
     [bound, bound, bound]],
     {});
 var p = view.create('point3d', [1, 2, 2], { name:'A', size: 5 });
 // Lines through 2 points
 var l1 = view.create('line3d', [[1, 3, 3], [-3, -3, -3]], {point1: {visible: true}, point2: {visible: true} });
 var l2 = view.create('line3d', [p, l1.point1]);

 // Line by point, direction, range
 var l3 = view.create('line3d', [p, [0, 0, 1], [-2, 4]]);

var view = board.create(
     'view3d',
     [[-6, -3], [8, 8],
     [[-3, 3], [-3, 3], [-3, 3]]],
     {
         depthOrder: {
             enabled: true
         },
         projection: 'parallel',
         xPlaneRear: { fillOpacity: 0.2 },
         yPlaneRear: { fillOpacity: 0.2 },
         zPlaneRear: { fillOpacity: 0.2 }
     }
 );


var A = view.create('point3d', [-2, 0, 1], { size: 2 });
var B = view.create('point3d', [-2, 0, 2], { size: 2 });
var line1 = view.create('line3d', [A, B], {
    fixed: false,
    strokeColor: 'blue',
    straightFirst: true,
    straightLast: true
});

var C = view.create('point3d', [2, 0, 1], { size: 2 });
var line2 = view.create('line3d', [C, line1, [-Infinity, Infinity]], { strokeColor: 'red' });

Attributes

Own

point

Description

Attributes of the defining point in case the line is defined by [point, vector, [range]]

Type
Point3D
Default Value
{ visible: false, name: ""}
Source
options3d.js, line 858

point1

Description

Attributes of the first point in case the line is defined by [point, point].

Type
Point3D
Default Value
{visible: false, name: ""}
Source
options3d.js, line 867

point2

Description

Attributes of the second point in case the line is defined by [point, point].

Type
Point3D
Default Value
{visible: false, name: ""}
Source
options3d.js, line 876

straightFirst

Description

If the 3D line is defined by two points and if this attribute is true, the 3D line stretches infinitely in direction of its first point. Otherwise it ends at point1.

Type
Boolean
Default Value
false
See
Source
options3d.js, line 885

straightLast

Description

If the 3D line is defined by two points and if this attribute is true, the 3D line stretches infinitely in direction of its second point. Otherwise it ends at point2.

Type
Boolean
Default Value
false
See
Source
options3d.js, line 899

Inherited

Members

Own

direction : Array|function

Description

Direction which - together with a point - defines the line. Array of numbers or functions (of length 3) or function returning array of length 3.

Type
Array | function
See
Source
3d/linspace3d.js, line 74

endpoints : Array

Description

Array of length 2 containing the endings of the Line3D element. These are the defining points, the intersections of the line with the bounding box, or the endings defined by the range.

Type
Array
Source
3d/linspace3d.js, line 742

(private) getPointCoords

Description

Determine one end point of a 3D line from point, direction and range).

Source
3d/linspace3d.js, line 165

(private) point1 : JXG.Point3D

Description

Starting point of the 3D line

Type
JXG.Point3D
Source
3d/linspace3d.js, line 103

(private) point2 : JXG.Point3D

Description

End point of the 3D line

Type
JXG.Point3D
Source
3d/linspace3d.js, line 111

range : Array

Description

Range [r1, r2] of the line. r1, r2 can be numbers or functions. The 3D line goes from (point + r1 * direction) to (point + r2 * direction)

Type
Array
Default Value
[-Infinity, Infinity]
Source
3d/linspace3d.js, line 94

vec : Array

Description

Spanning vector of the 3D line. Contains the evaluated coordinates from direction and range. The array has length 4, the first entry being 0.

Type
Array
Source
3d/linspace3d.js, line 84

(static) point : Point3D

Description

3D point which - together with a direction - defines the line.

Type
Point3D
See
Source
3d/linspace3d.js, line 64

Inherited

Methods

Own

(private) setPosition2D(t)

Set the 2D position of the defining points.

Parameters

Name Type Description
t Transformation

projective 2D transformation

Details

Source
3d/linspace3d.js, line 250

(private) updateCoords() → {Object}

Update the array Line3D#vec containing the homogeneous coords of the spanning vector.

Returns

Reference to Line3D object

Type
Object

Details

Source
3d/linspace3d.js, line 132

updateZIndex() → {Object}

Update the z-index of the line, i.e. the z-index of its midpoint.

Returns

Reference to Line3D object

Type
Object

Details

Source
3d/linspace3d.js, line 319

Inherited

Events

Own

none

Inherited

Throws

If the element cannot be constructed with the given parent objects an exception is thrown.

Type
Exception

Details

Type
JXG.Line3D
Source
3d/linspace3d.js, line 341

Extends