Calculates the intersection of a ray defined by an origin and an end point with an entity.
Calculates the intersection of a ray defined by an origin and an end point with an entity.
Value parameters
end
The end point of the ray.
entity
The entity to check for intersection.
origin
The starting point of the ray.
Attributes
Returns
An Option[Double] representing the distance from the origin to the intersection point along the ray. If there is no intersection, it returns None.
Note
The ray is defined as a line segment from origin to end. The function checks if this ray intersects with the entity's shape. If the entity is a circle, it checks for intersection with the circle's perimeter. If the entity is a rectangle, it checks for intersection with the rectangle's edges. The function returns the distance from the origin to the intersection point along the ray, if an intersection occurs. If there is no intersection, it returns None.