# ray vs OBB

This topic is 4847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i have made algorithm for intersecting 3d ray ( p0 + t.K ) with an OBB and it didn't work well here is the code: bool intersect(SOBB& b,SRay3D& s,SVector3D& p) { SRay3D convS; // the ray in b coordinates SVector3D c_c = s.p0 - c; // translate vector // converting the ray elements into ray frame convS.p0.set( c_c.Dot(b.u[0]) , c_c.Dot(b.u[1]) ,c_c.Dot(b.u[2]) ); convS.d.set( s.d.Dot(b.u[0] ) , s.d.Dot(b.u[1]) ,s.d.Dot(b.u[2]) ); // now the converted ray with aabb ( obb is now aabb for new ray ) SAABB ab; ab.min.set(-b.e[0],-b.e[1],-b.e[2]); ab.max.set( b.e[0], b.e[1], b.e[2]); float t; if( ab.intersect(convS,t,p) ) { // re-write the intersection point in world coordinates float x = b.c.x + p.Dot(xAxis); float y = b.c.y + p.Dot(yAxis); float z = b.c.z + p.Dot(zAxis); p.set(x,y,z); return true; } return false; } please help me what is the mistake in my code???

##### Share on other sites
Assuming ab.intersect() works correctly, I would then try replacing these lines:

float x = b.c.x + p.Dot(xAxis);
float y = b.c.y + p.Dot(yAxis);
float z = b.c.z + p.Dot(zAxis);

p.set(x,y,z);

With this:

p = b.c + p.x * b.u[0] + p.y * b.u[1] + p.z * b.u[2];

And see if that doesn't fix the problem.

##### Share on other sites
okay that's exactly my mistake converting back to old frame.
thanks a lot.

1. 1
2. 2
Rutin
15
3. 3
4. 4
5. 5

• 9
• 9
• 14
• 12
• 10
• ### Forum Statistics

• Total Topics
633268
• Total Posts
3011142
• ### Who's Online (See full list)

There are no registered users currently online

×