🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Ray intersection on (axis aligned) swept curve?

Started by
0 comments, last by Neoshaman 5 years, 9 months ago

I'm struggling to find the correct way to make ray intersection with curve that are swept along an axis.
In theory I thought it should be simple, I decompose the problem into component:
- find intersection on the curve (cross section), which is easy
- extrude that intersection point into an axis aligned line, solve the slope intersection to that line to get the final offset.

To be sure I got it right, I'm starting with a swept 45° line centered on origin (line-plane intersection with dot product would be more efficient, but remember I'm trying to validating swiping a long a line).
- line equation is origine + directionVector * t
- line to line intersection equation is t = (origine1 - origine2)/(directionVector2 - directionVector1) >> assuming they are never parallel.

So let line2dIntersection(directionVector1,origine1,directionVector2,origine2)

Assuming the ray start on the xy plane (pseudo code):
- I first compute the cross section into xz
intersection1 = line2dIntersection(rayDir.xz, vector2(origine.x,0), vector2(1,1).normalize(), vector2(0,0));
result.xz = raydir.xz * intersection1;

-Then find the slope swipe offset into yz
intersection2 = line2dIntersection(rayDir.yz, vector2(origine.y,0), vector2(1,0).normalize(), vector2(0,result.z));
result.y = raydir.y * intersection2;

But all my result are garbage. What am I doing wrong? where is the leap of logic I did?

>>>>>>>>>>>>>>>be goodbe evilbut do it WELL>>>>>>>>>>>>>>>

This topic is closed to new replies.

Advertisement