class nape.geom.Ray

Available on all platforms

Parametrically defined ray used in ray casting functions.

Class Fields

static function fromSegment(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. * *

start

Start point of line segment *

end

End point of line segment *

returns

A Ray representing this line segment. *

Instance Fields

var 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.

var 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. * * @default infinity

var origin:Vec2

Origin of ray. *

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

var userData:DynamicDynamic

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. * * @default {}

var zpp_inner:ZPP_Ray

@private

function new(origin:Vec2, direction:Vec2):Void

Construct new Ray. * *

origin

Origin of ray. *

direction

Direction of ray. *

function 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.

function 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. * *

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.

function copy():Ray

Produce a copy of this ray. *

* All ray properties will be copied including maxDistance. * *

returns

The copy of this Ray.