12 UInt32 unSolutionCount = 0;
15 CVector3 cRelTopCap = m_fHeight * m_cAxis;
23 Real fDRA = m_cAxis.DotProduct(cRayDir);
24 CVector3 cAlpha = cRayDir - fDRA * m_cAxis;
31 pfSolutions[0] = -fB / (2.0 * fA);
32 if(pfSolutions[0] > 0.0) {
33 CVector3 cTest = cPRA + pfSolutions[0] * cRayDir;
34 if(m_cAxis.DotProduct(cTest) > 0) {
36 if(m_cAxis.DotProduct(cTest) < 0) {
46 pfSolutions[0] = (-fB +
Sqrt(fDelta)) / (2.0 * fA);
47 if(pfSolutions[0] > 0.0) {
48 cTest = cPRA + pfSolutions[0] * cRayDir;
49 if(m_cAxis.DotProduct(cTest) > 0) {
51 if(m_cAxis.DotProduct(cTest) < 0) {
57 pfSolutions[unSolutionCount] = (-fB -
Sqrt(fDelta)) / (2.0 * fA);
58 if(pfSolutions[unSolutionCount] > 0.0) {
59 cTest = cPRA + pfSolutions[unSolutionCount] * cRayDir;
60 if(m_cAxis.DotProduct(cTest) > 0) {
62 if(m_cAxis.DotProduct(cTest) < 0) {
76 pfSolutions[unSolutionCount] = -fPPRA / fDRA;
77 if(pfSolutions[unSolutionCount] > 0.0 &&
78 (cPRA + pfSolutions[unSolutionCount] * cRayDir).SquareLength() <
Square(m_fRadius)) {
82 pfSolutions[unSolutionCount] = -(fPPRA - m_fHeight) / fDRA;
83 if(pfSolutions[unSolutionCount] > 0.0 &&
84 (cPRA - cRelTopCap + pfSolutions[unSolutionCount] * cRayDir).SquareLength() <
Square(m_fRadius)) {
91 if(unSolutionCount == 0) {
94 f_t_on_ray = pfSolutions[0];
95 for(
UInt32 i = 1; i < unSolutionCount; ++i) {
96 if(pfSolutions[i] < f_t_on_ray)
97 f_t_on_ray = pfSolutions[i];
unsigned int UInt32
32-bit unsigned integer.
float Real
Collects all ARGoS code.
The namespace containing all the ARGoS related code.
T Square(const T &t_v)
Returns the square of the value of the passed argument.
bool Intersects(Real &f_t_on_ray, const CRay3 &c_ray)
void GetDirection(CVector3 &c_buffer) const
Real SquareLength() const
Returns the square length of this vector.
Real DotProduct(const CVector3 &c_vector3) const
Returns the dot product between this vector and the passed one.