Skip to main content

Class: Ray

Defined in: physics/raycast.ts:82

Ray class that represents a ray in 2D space.

Constructors

Constructor

new Ray(start, end): Ray

Defined in: physics/raycast.ts:92

Creates a new Ray object.

Parameters

start

Vector2

The starting point of the ray

end

Vector2

The ending point of the ray

Returns

Ray

Properties

end

end: Vector2

Defined in: physics/raycast.ts:84


start

start: Vector2

Defined in: physics/raycast.ts:83


vertices

vertices: Vector2[] = []

Defined in: physics/raycast.ts:85

Accessors

difference

Get Signature

get difference(): Vector2

Defined in: physics/raycast.ts:279

Returns

Vector2


isHorizontal

Get Signature

get isHorizontal(): boolean

Defined in: physics/raycast.ts:294

Returns

boolean


isVertical

Get Signature

get isVertical(): boolean

Defined in: physics/raycast.ts:298

Returns

boolean


offsetY

Get Signature

get offsetY(): number

Defined in: physics/raycast.ts:287

Returns

number


slope

Get Signature

get slope(): number

Defined in: physics/raycast.ts:283

Returns

number

Methods

calculateNormal()

calculateNormal(referencePoint): Vector2

Defined in: physics/raycast.ts:261

Calculates the normal vector of the ray at the specified reference point.

Parameters

referencePoint

Vector2

The reference point to calculate the normal vector from

Returns

Vector2

The normal vector of the ray at the specified reference point


pointInBounds()

pointInBounds(point): boolean

Defined in: physics/raycast.ts:243

Checks if a point is within the bounds of the ray.

Parameters

point

Vector2

The point to check

Returns

boolean

True if the point is within the bounds of the ray, false otherwise


xValueAt()

xValueAt(y): number

Defined in: physics/raycast.ts:231

Returns the x value on the ray at the specified y.

Parameters

y

number

The y value to check

Returns

number

The x value on the ray at the specified y


yValueAt()

yValueAt(x): number

Defined in: physics/raycast.ts:219

Returns the y value on the ray at the specified x.

Parameters

x

number

The x value to check

Returns

number

The y value on the ray at the specified x


bodyCollisions()

static bodyCollisions(rayA, body): RaycastCollision[]

Defined in: physics/raycast.ts:186

Parameters

rayA

Ray

body

Body

Returns

RaycastCollision[]


bodyEdges()

static bodyEdges(body): Ray[]

Defined in: physics/raycast.ts:149

Parameters

body

Body

Returns

Ray[]


collisionPoint()

static collisionPoint(rayA, rayB): null | Vector2

Defined in: physics/raycast.ts:131

Parameters

rayA

Ray

rayB

Ray

Returns

null | Vector2


intersect()

static intersect(rayA, rayB): null | Vector2

Defined in: physics/raycast.ts:97

Parameters

rayA

Ray

rayB

Ray

Returns

null | Vector2