Skip to main content
GameDev.net gamedev.net
🔒 Locked

3d math issue

Started by Holden Oct 26, 2000 at 7:57 PM 3 replies 700+ views
Original Post
Holden
Holden
Ok, the problem is like that: I have 2 surfaces ( 3d triangles ) in the 3d space. I dont know their reletive position to each other , but I do know all the information (x,y,z) about those two surfaces. As for the problem... How can I align surface #1 in a way it will be parallel to surface #2 ? The story behind the problem is as follows: I am making a small tank strategy and I have tanks and mountains. I need to align each tank on its current position on the mountain in a way that it will look like the tank is really climbing those mountains, instead like he took an elevator... B.T.W: the mountain is a bunch of triangles, so each surface is a triagnle and not a square. answer (hopefully) will be send to preshel@mailcity.com Thanks.
Zipster
Zipster
First you need the relative positions for the "source" triangle (the relationship of the 3 points on each triangle to each other, i mean, and in this case it would be your mountain triangle). Select a point on the first triangle. Then you select a point on the second triangle triangle, most likely the one that is "similar" (geometrically speaking, "same" point) to the point on the first triangle (this is your tank triangle). Using the relationship of the points found in your "source" triangle, copy them to the "tank" triangle.
loserkid
loserkid
Hello, here is another idea:

First I assume you have the normals to both of the surfaces. Take the normals and use the dot product to find the angle between them (angle between the the two triangles). Second rotate one of the triangles (the one you want to make parallel to the other) by the angle (make it a negative) you found from step one. then the angle between them will be zero and they will be parallel.

hope this helped... and made sense.
JP.

==============================================
I feel like a kid in some kind of store...
==============================================
www.thejpsystem.com
==============================================I feel like a kid in some kind of store... ============================================== www.thejpsystem.com
shankel
shankel
quote:
Original post by loserkid

Hello, here is another idea:

First I assume you have the normals to both of the surfaces. Take the normals and use the dot product to find the angle between them (angle between the the two triangles). Second rotate one of the triangles (the one you want to make parallel to the other) by the angle (make it a negative) you found from step one. then the angle between them will be zero and they will be parallel.

hope this helped... and made sense.
JP.




You''ll also need the axis of rotation. You can get this by taking the cross-product of the two normals.

Jason
Jason ShankelMaxis/EA
baskuenen
baskuenen
Using a triangle as the bottom of your tank (or vehicle) is probably not what you want.
It may be better to take 4 points for the tires on the vehicle (or outer points on the tank tracks).

I haven''t tried it yet - but I would do the following:
- Calc the height for the 4 points.
- With 4 points you can form 4 triangles, so do the following test 4 times:
- - Make a triangle out of 3 points.
- - Calc plane equation out of this.
- - Test if point 4 is under this plane. If it is: use this plane, if not, go on checking...

With above algo, you can have a tire lose from the ground. This is probably what you want!?...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.