# Ray

## Description

`struct` `Tinman.Core.Math.Ray`

A ray in 3D space.

## Public / Constants

### Undefined

`public` `static` `readonly` `attribute` `Undefined` → `(Ray)`

The undefined ray.

Ray.IsUndefined

## Public / Constructors

### For​Direction

`[Pure]`
`public` `static` `method` `ForDirection1` → `(2)`

origin in : Vec3D

The start point of the ray.

direction in : Vec3D

The direction vector of the ray. The vector will be normalized to unit length.

returns → Ray

The ray originating at origin in, pointing in direction in.

Creates a ray that starts at origin in and points into the given direction in.

`[Pure]`
`public` `static` `method` `ForDirection2` → `(3)`

origin in : Vec3D

The start point of the ray.

direction in : Vec3D

The direction vector of the ray. The vector will be normalized to unit length.

ray out : Ray

The ray originating at origin in, pointing in direction in.

returns → float64

Length of direction in.

Creates a ray that starts at origin in and points into the given direction in.

### For​Target

`[Pure]`
`public` `static` `method` `ForTarget1` → `(2)`

origin in : Vec3D

The start point of the ray.

target in : Vec3D

The target point of the ray.

returns → Ray

The ray originating at origin in, pointing towards target in.

Creates a ray that starts at origin in and points towards target in.

`[Pure]`
`public` `static` `method` `ForTarget2` → `(3)`

origin in : Vec3D

The start point of the ray.

target in : Vec3D

The target point of the ray.

ray out : Ray

The ray originating at origin in, pointing towards target in.

returns → float64

The distance between origin in and target in.

Creates a ray that starts at origin in and points towards target in.

### Ray

`public` `constructor` `Ray` → `(2)`

origin in : Vec3D

The ray origin.

direction in : Vec3D

The unit-length ray direction.

Creates a new instance of Ray.

## Public / Methods

### Distance

`[Pure]`
`public` `method` `Distance1` → `(1)`

in : float64

The distance along Direction.

returns → Vec3D

The point.

Returns the point at the given distance along the ray Direction from the ray Origin.

`[Pure]`
`public` `method` `Distance2` → `(1)`

in : Vec3D

The point.

returns → float64

The distance along Direction.

Returns the distance of the given point along the ray Direction from the ray Origin.

`[Pure]`
`public` `method` `Distance3` → `(3)`

in : float64

X-coordinate of the point.

in : float64

Y-coordinate of the point.

in : float64

Z-coordinate of the point.

returns → float64

The distance of the given point along this ray.

Returns the distance of the given point along this ray.

### Intersect

`[Pure]`
`public` `method` `Intersect1` → `(1)`

plane in : Plane

The plane to intersect with.

returns → Vec3D

The intersection point or Vec3D.Undefined if there is no intersection.

Intersects this ray with the given plane.

`[Pure]`
`public` `method` `Intersect2` → `(1)`

sphere in : Sphere

The sphere to intersect with.

returns → Vec3D

The intersection point or Vec3D.Undefined if there is no intersection.

Intersects this ray with the given sphere.

### Scale

`[Pure]`
`public` `method` `Scale` → `(1)`

factor in : float64

The scale factor.

returns → Ray

The scaled ray.

Scales this ray.

## Public / Attributes

### Direction

`public` `readonly` `attribute` `Direction` → `(Vec3D)`

The unit-length ray direction vector.

### Is​Undefined

`public` `attribute` `IsUndefined` → `(get)`

value : bool

`true` if this ray is undefined, `false` if not.

Is this ray undefined?

Ray.Undefined

### Origin

`public` `readonly` `attribute` `Origin` → `(Vec3D)`

The origin of the ray.

## Serialization

### Serializer

`public` `static` `readonly` `attribute` `Serializer` → `(ITypeSerializer<Ray>)`

The serialization helper object for values of Ray.