Kale
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Kale::Ray Struct Reference

#include <Ray.hpp>

+ Inheritance diagram for Kale::Ray:

Public Member Functions

 Ray ()
 
 Ray (const Vector2f &origin, const Vector2f &direction)
 
 Ray (const Vector2f &origin, float angle, AngleUnit unit)
 
 Ray (const Line &line)
 
float getAngle (AngleUnit unit) const
 
bool isPerpendicular (Ray ray) const
 
bool isPerpendicular (Line line) const
 
bool isParallel (Ray ray) const
 
bool isParallel (Line line) const
 
Rect getBoundingBox () const override
 
bool pointCollision (Vector2f point) const override
 
bool rectCollision (RotatedRect rect) const override
 
bool rectCollision (Rect rect) const override
 
bool circleCollision (Circle circle) const override
 
bool rayCollision (Ray ray) const override
 
bool lineCollision (Line line) const override
 

Public Attributes

Vector2f origin
 
Vector2f direction
 

Detailed Description

Represents a ray coming from a point

Definition at line 28 of file Ray.hpp.

Constructor & Destructor Documentation

◆ Ray() [1/4]

Ray::Ray ( )

Creates a ray originating from 0, 0 and pointing right

Definition at line 32 of file Ray.cpp.

◆ Ray() [2/4]

Ray::Ray ( const Vector2f & origin,
const Vector2f & direction )

Creates a new ray given the origin and direction unit vector

Parameters
originThe origin of the ray
directionThe direction unit vector, must have a magnitude of 1.

Definition at line 41 of file Ray.cpp.

◆ Ray() [3/4]

Ray::Ray ( const Vector2f & origin,
float angle,
AngleUnit unit )

Creates a new ray given the origin and angle of casting

Parameters
originThe origin of the ray
angleThe angle of casting
unitThe type of angle unit given

Definition at line 59 of file Ray.cpp.

◆ Ray() [4/4]

Ray::Ray ( const Line & line)

Creates a new ray from a line with the first point as the origin pointing towards the second point

Parameters
lineThe line to create from

Definition at line 49 of file Ray.cpp.

Member Function Documentation

◆ circleCollision()

bool Ray::circleCollision ( Circle circle) const
overridevirtual

Checks for collision with a circle

Parameters
circleThe circle to check collision for
Returns
True if there is a collision, false for no collision

Implements Kale::Geometry.

Definition at line 158 of file Ray.cpp.

◆ getAngle()

float Ray::getAngle ( AngleUnit unit) const

Gets the angle of the direction

Parameters
unitThe type of unit to return the angle in
Returns
the angle of the direction

Definition at line 69 of file Ray.cpp.

◆ getBoundingBox()

Rect Ray::getBoundingBox ( ) const
overridevirtual

Gets a bounding box for this geometry to check for quick and inaccurate collisions

Returns
The bounding box

Implements Kale::Geometry.

Definition at line 115 of file Ray.cpp.

◆ isParallel() [1/2]

bool Ray::isParallel ( Line line) const

Checks whether or not the line is parallel with this ray

Parameters
lineThe line to check with
Returns
Whether or not the line is parallel with this ray

Definition at line 107 of file Ray.cpp.

◆ isParallel() [2/2]

bool Ray::isParallel ( Ray ray) const

Checks whether or not the ray is parallel with this ray

Parameters
rayThe ray to check with
Returns
Whether or not the ray is parallel with this ray

Definition at line 98 of file Ray.cpp.

◆ isPerpendicular() [1/2]

bool Ray::isPerpendicular ( Line line) const

Checks whether or not the line is perpendicular with this ray

Parameters
lineThe line to check with
Returns
Whether or not the line is perpendicular with this ray

Definition at line 89 of file Ray.cpp.

◆ isPerpendicular() [2/2]

bool Ray::isPerpendicular ( Ray ray) const

Checks whether or not the ray is perpendicular with this ray

Parameters
rayThe ray to check with
Returns
Whether or not the ray is perpendicular with this ray

Definition at line 80 of file Ray.cpp.

◆ lineCollision()

bool Ray::lineCollision ( Line line) const
overridevirtual

Checks for collision with a line

Parameters
lineThe line to check collision for
Returns
True if there is a collision, false for no collision

Implements Kale::Geometry.

Definition at line 193 of file Ray.cpp.

◆ pointCollision()

bool Ray::pointCollision ( Vector2f point) const
overridevirtual

Checks for collision with a point

Parameters
pointThe point to check collision for
Returns
True if there is a collision, false for no collision

Implements Kale::Geometry.

Definition at line 128 of file Ray.cpp.

◆ rayCollision()

bool Ray::rayCollision ( Ray ray) const
overridevirtual

Checks for collision with a ray

Parameters
rayThe ray to check collision for
Returns
True if there is a collision, false for no collision

Implements Kale::Geometry.

Definition at line 167 of file Ray.cpp.

◆ rectCollision() [1/2]

bool Ray::rectCollision ( Rect rect) const
overridevirtual

Checks for collision with a rectangle

Parameters
rectThe rectangle to check collision for
Returns
True if there is a collision, false for no collision

Implements Kale::Geometry.

Definition at line 148 of file Ray.cpp.

◆ rectCollision() [2/2]

bool Ray::rectCollision ( RotatedRect rect) const
overridevirtual

Checks for collision with a rectangle

Parameters
rectThe rectangle to check collision for
Returns
True if there is a collision, false for no collision

Implements Kale::Geometry.

Definition at line 138 of file Ray.cpp.

Member Data Documentation

◆ direction

Vector2f Kale::Ray::direction

The unit vector representing the direction of the ray

Definition at line 38 of file Ray.hpp.

◆ origin

Vector2f Kale::Ray::origin

The origin of the ray

Definition at line 33 of file Ray.hpp.


The documentation for this struct was generated from the following files: