# B.Math.Ray()

Represents a ray.

To create the object use B.Math.makeRay().

## PROPERTIES:

origin

Origin of the ray.

direction

Direction of the ray.

## METHODS:

clone()

Clones this ray to a new ray.

### RETURNS:

this

copy(ray)

Copies a given ray into this ray.

ray

### RETURNS:

this

set(origin, direction)

Sets this ray from an origin and a direction.

origin

direction

### RETURNS:

this

fromArray(array, offset)

Sets this ray from a part of array.

### PARAMETERS:

{Array.<number>} array

{number} [offset] = 0

### RETURNS:

{number}

new offset

toArray(array, offset)

Sets this ray to a part of array.

### PARAMETERS:

{Array.<number>} array

{number} [offset] = 0

### RETURNS:

{number}

new offset

fromOriginTarget(origin, target)

Sets this ray from an origin and a target.

origin

target

### RETURNS:

this

translate(offset)

Translates this ray by a given offset.

offset

### RETURNS:

this

transform(matrix)

Transforms this ray by a 4x4 matrix.

matrix

### RETURNS:

this

at(t, result)

Gets a point at this ray.

### PARAMETERS:

{number} t

[0, +Infinity]

[result]

omit if you want to return newly created vector

### RETURNS:

point

projectPoint(point, result)

Projects a point to this ray.

### PARAMETERS:

point

[result]

omit if you want to return newly created vector

### RETURNS:

projected point

trace(object, point)

Finds the point of intersection between this ray and an object.

### PARAMETERS:

object

[point]

point of intersection

### RETURNS:

{number | null}

distance from origin or null if no intersections

### THROWS:

{Error}

if the object argument has unsupported type

distanceTo(object)

Calculates the shortest distance between this ray and an object.

object

{number}

distance

### THROWS:

{Error}

if the object argument has unsupported type

equal(ray)

Checks for strict equality of this ray and another ray.

ray

{boolean}