Parametrically defined ray used in ray casting functions.

Static methods

staticfromSegment(start:Vec2, end:Vec2):Ray

Create ray representing a line segment.

This function will a ray who's origin is the start point and who's direction is towards the end point with the maxDistance property appropriately set to not extend beyond the end point.

Parameters:

start

Start point of line segment

end

End point of line segment

Returns:

A Ray representing this line segment.

Throws:

#

If start or end are either null or disposed of.

#

If start and end point are equal so that the direction of the ray would be degenerate.

Constructor

new(origin:Vec2, direction:Vec2)

Construct new Ray.

Parameters:

origin

Origin of ray.

direction

Direction of ray.

Throws:

#

If origin or direction are null, or disposed of.

#

If direction is degenerate.

Variables

@:value(null)zpp_inner:ZPP_Ray = null

@private

read onlyuserData:Dynamic<Dynamic>

Dynamic object for user to store additional data.

This object cannot be set, only its dynamically created properties may be set. In AS3 the type of this property is &#42

This object will be lazily constructed so that until accessed for the first time, will be null internally.

origin:Vec2

Origin of ray.

This property can be set, and is equivalent to performing: ray.origin.set(newOrigin)

direction:Vec2

Direction of ray.

This property can be set, and is equivalent to performing: ray.direction.set(newDirection) with the additional constraint that the input direction must not be degenerate.

This direction vector need not be normalised.

maxDistance:Float

The maximum distance for ray to be queried.

When used in ray test functions, no search will extend beyond this distance.

This value represents a true distance, even if direction vector is not normalised. This value may be equal to infinity.

Methods

aabb():AABB

Compute bounding box of ray.

This function will take into account the maxDistance property of this ray.
The return AABB may have in the general case infinite values :)

Returns:

An AABB representing bounding box of ray.

@:value({ weak : false })at(distance:Float, weak:Bool = false):Vec2

Compute point along ray at given distance.

Even if ray direction is not normalised, this value still repersents a true distance. The distance may also be negative.

The Vec2 returned will be allocated from the global object pool.

Parameters:

distance

The distance along ray to compute point for.

weak

If true then a weakly allocated Vec2 will be returned which will be automatically released to global object pool when used as argument to another Nape function. (default false)

Returns:

Vec2 representing point at given distance along ray.

copy():Ray

Produce a copy of this ray.

All ray properties will be copied including maxDistance.

Returns:

The copy of this Ray.