paysages3d/src/basics/InfiniteCylinder.h

54 lines
1.1 KiB
C
Raw Permalink Normal View History

#pragma once
2015-10-15 18:21:32 +00:00
#include "basics_global.h"
#include "InfiniteRay.h"
namespace paysages {
namespace basics {
/**
* Geometric cylinder, with infinite length.
*/
class BASICSSHARED_EXPORT InfiniteCylinder {
public:
InfiniteCylinder() = default;
2015-10-15 18:21:32 +00:00
InfiniteCylinder(const InfiniteRay &axis, double radius);
2015-12-15 23:31:07 +00:00
virtual ~InfiniteCylinder();
2015-10-15 18:21:32 +00:00
inline const InfiniteRay &getAxis() const {
return axis;
}
inline double getRadius() const {
return radius;
}
2015-10-15 18:21:32 +00:00
/**
* Check the intersection between the cylinder and an infinite ray.
*
* Returns the number of intersections (0, 1 or 2) and fill the intersection points.
*/
int findRayIntersection(const InfiniteRay &ray, Vector3 *first_intersection, Vector3 *second_intersection) const;
2015-10-15 18:21:32 +00:00
virtual void save(PackStream *stream) const;
virtual void load(PackStream *stream);
private:
void validate();
protected:
2015-10-15 18:21:32 +00:00
InfiniteRay axis;
double radius;
private:
// Stored equation factors, to speed up ray intersection
double R[3][3];
double A[3][3];
double C;
double ox;
double oy;
double oz;
2015-10-15 18:21:32 +00:00
};
}
}