Ray3d
Represents an immutable ray (or line) in 3d coordinates
SDK 2.37.0
Constructor
Section titled “Constructor”Constructor
Section titled “Constructor”new Ray3d(
origin,direction):Ray3d
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The origin point of this ray |
|
|
|
‐ |
Returns
Section titled “Returns”Ray3d
Properties
Section titled “Properties”direction
Section titled “direction”
readonlydirection:Vector3d
The normalized direction vector for this ray
origin
Section titled “origin”
readonlyorigin:Point3d
The origin point of this ray
Methods
Section titled “Methods”projectPoint()
Section titled “projectPoint()”projectPoint(
point):Point3d
Projects the given point onto this line
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”SDK 2.37.0
toString()
Section titled “toString()”toString():
string
Returns
Section titled “Returns”string
between()
Section titled “between()”
staticbetween(start,end):Ray3d
Constructs a ray (line) between two points.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
|
|
|
‐ |
Returns
Section titled “Returns”Ray3d
Example
Section titled “Example”let { Ray3d } = SketchUpApi;let ray = Ray3d.between([0,0,0],[1,0,0]);console.log(ray.toString());Throws
Section titled “Throws”Error if start and end are the same
SDK 2.37.0
create()
Section titled “create()”
staticcreate(input):Ray3d
Creates a Ray from any input that can be interpreted as a Ray.
NOTE For a tuple the second argument is assumed to be a vector rather than a point unless a Point3d is explicitly supplied.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”Ray3d
Example
Section titled “Example”let { Point3d, Ray3d } = SketchUpApi;// Interpreted as Point+Vectorlet a = Ray3d.create([[0,0,0],[1,0,0]]);// Interpreted as Point+Pointlet b = Ray3d.create([[0,0,0],new Point3d(1,0,0)]);console.log(a.toString(),b.toString());SDK 2.37.0
Throws
Section titled “Throws”Error on invalid input