Ray
Ray
Overview
Description
A Ray represents a ray in 3D space. It is defined by two properties: the origin and the direction. It is commonly used in calculations such as collision detection, raycasting, and geometry operations.
Constructors
new
Creates a new Ray instance with the given Origin and Direction.
Parameters
Vector3 InOrigin
The origin point of the ray in 3D space.
Vector3 InDirection
The direction vector of the ray. It is usually normalized.
Return
Ray
A new Ray instance.
Code Samples
local Origin = Vector3.new(0, 50, 0)
local Direction = Vector3.new(0, 0, -3000)
local Ray = Ray.new(Origin, Direction)
print(Ray)Properties
Origin
Vector3 The starting point of the ray in 3D space.
Code Samples
local Origin = Vector3.new(0, 50, 0)
local Direction = Vector3.new(0, 0, -3000)
local Ray = Ray.new(Origin, Direction)
print(Ray.Origin)Direction
Vector3 The normalized vector indicating the direction of the ray.
Code Samples
local Origin = Vector3.new(0, 50, 0)
local Direction = Vector3.new(0, 0, -3000)
local Ray = Ray.new(Origin, Direction)
print(Ray.Direction)Unit
Ray where the direction vector is normalized.
Code Samples
Methods
ClosestPoint
Finds the closest point on the ray to a given point in 3D space.
Parameters
Vector3 InPoint
The point in 3D space to find the closest point to.
Return
Vector3
The closest point on the ray to the provided point.
Code Samples
Distance
Calculates the perpendicular distance between the ray and a given point.
Parameters
Vector3 InPoint
The point in 3D space to calculate the perpendicular distance to.
Return
number
The distance between the ray and the point.
Code Samples
Last updated