Game Development Community

Math Challenged

by Michael Cozzolino · in Technical Issues · 08/04/2006 (9:22 am) · 5 replies

I'm doing a raycast against an interior or vertical Terrain in the case of TSE and I want the position that is parallel between the player position and position returned from the raycast that is 90 degrees parallel to the raycast return position. I provided a diagram of an example. Any position along the dotted line is what i'm looking for.

img242.imageshack.us/img242/4495/questionbx2.th.jpg

About the author

Indie Developer in the Albany NY area. iOS, PC, Mac OSX development. http://itunes.apple.com/us/artist/michael-cozzolino/id367780489


#1
08/04/2006 (9:32 am)
Pesudo.

vector playerToRay = vector ray - vector player
vector up = 0, 1, 0

vector right = playerToRay x up // NOTE cross product, not *

This gets you a vector adjacent (90 degrees) to the raycast vector.
#2
08/04/2006 (10:07 am)
Westy I think Michael is interested in obtaining the vector which is perpendicular to the interior wall at the point of incidence of the ray, rather than a vector perpendicular to the ray.

Michael you can just use containerraycast for what you want. the containerRayCast function not only returns the position of impact, it also returns the normal of the surface the ray hit.
#3
08/04/2006 (10:13 am)
Thanks Sean. I understand that but I guess i'm not sure what to do with the surface normal? Are you implying that I could get a position im looking for along the vector I demonstrate with dashes by using the surface normal?
#4
08/04/2006 (11:04 am)
Yes. I believe the containerraycast function will return the position the ray hits the wall, and the normal of the wall at that point. so, placing or moving something along that dotted line would involve setting the proper position first, and then setting the proper direction vector. you can probably use the position and normal information returned by containerraycast for what you need. if you use the exact position returned by the function, youll start at the point along the dotted line right next to the wall. you could also choose a different point along the dotted line by scaling the normal vector returned by the function by a certain amount and adding that vector to the position returned by the function.

if all of this is gibberish to you then you probably should read some tutorials on 3d vector math.

hope this helps.
#5
08/07/2006 (7:49 am)
Thank you Sean. I think I have it working. You helped with the final piece of the puzzle. :)