-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsray3d.h
48 lines (40 loc) · 1.34 KB
/
qgsray3d.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef QGSRAY3D_H
#define QGSRAY3D_H
#include "qgsbox3d.h"
#include <QVector3D>
/**
* \ingroup core
* A representation of a ray in 3D.
*
* A ray is composed of an origin point (the start of the ray) and a direction vector.
*
* \since QGIS 3.18
*/
class CORE_EXPORT QgsRay3D
{
public:
QgsRay3D( const QVector3D &origin, const QVector3D &direction );
//! Returns the origin of the ray
QVector3D origin() const { return mOrigin; }
//! Returns the direction of the ray
QVector3D direction() const { return mDirection; }
//! Sets the origin of the ray
void setOrigin( const QVector3D &origin );
//! Sets the direction of the ray
void setDirection( const QVector3D direction );
/**
* Returns the projection of the point on the ray
* (which is the closest point of the ray to \a point)
*/
QVector3D projectedPoint( const QVector3D &point ) const;
//! Checks whether the ray intersects with \a box
bool intersectsWith( const QgsBox3d &box ) const;
//! Checks whether the point is in front of the ray
bool isInFront( const QVector3D &point ) const;
//! Returns the angle between the ray and the vector from the ray's origin and the point \a point
double angleToPoint( const QVector3D &point ) const;
private:
QVector3D mOrigin;
QVector3D mDirection;
};
#endif // QGSRAY3D_H