## 3D math library

You guys know any good free C++ library for 3D math?

I need stuff like "find plane orthogonal to given line pasing through given point", "find plane passing through 3 given points", "find line lying on given plane orthogonal to given line" and such.

I made my own functions up somehow, but they're very inefficient.

For instance, if you had to find the angle formed by 3 points (in 3D), how would you do that?

I need stuff like "find plane orthogonal to given line pasing through given point", "find plane passing through 3 given points", "find line lying on given plane orthogonal to given line" and such.

I made my own functions up somehow, but they're very inefficient.

For instance, if you had to find the angle formed by 3 points (in 3D), how would you do that?

Â©hâ‚¬ck Ã¸ut Âµy stuÆ’Æ’ Ã¥t ragdollsoft.com

New game in development Rubber Ninjas - Mac Games Downloads

If you have equations for all the different things, but there's just inefficient, why not post them and have some of us optimize them for you?

Damn, I always forget the dot product stuff.

I always end up doing some "too creative" stuff.

for instance to find the angle between the (x1,y1,z1), (x2,y2,z2) and (x3,y3,z3) I did like this:

-first you shift everything so that point 2 is in the origin

-then I normalize the length of vectors 1 and 3 to have length 1

-Then I find the distance between the new 1 and 3 points

-then I consider the the triangle formed by 1,2,3 and I know that it's isosceles so I split segment 1-3 in 2 parts and I know the two resulting smaller triangles are right triangles, I know their sides so I can calculate the angle with acos, which is half of the original angle.

When I guess it would have been enough to

-first you shift everything so that point 2 is in the origin

-then I normalize the length of vectors 1 and 3 to have length 1

-calculate the dot product

-find angle with acos

oh well.

The fist method works, but damn, I guess I took it too long.

The other functions use even more twisted ways, I'll post them for your amusement when I get back to the code.

But thanks for your interest akb825, it's hard to get people to look at your code, but it helps a lot if someone can tell you more direct techniques to get the results.

I always end up doing some "too creative" stuff.

for instance to find the angle between the (x1,y1,z1), (x2,y2,z2) and (x3,y3,z3) I did like this:

-first you shift everything so that point 2 is in the origin

-then I normalize the length of vectors 1 and 3 to have length 1

-Then I find the distance between the new 1 and 3 points

-then I consider the the triangle formed by 1,2,3 and I know that it's isosceles so I split segment 1-3 in 2 parts and I know the two resulting smaller triangles are right triangles, I know their sides so I can calculate the angle with acos, which is half of the original angle.

When I guess it would have been enough to

-first you shift everything so that point 2 is in the origin

-then I normalize the length of vectors 1 and 3 to have length 1

-calculate the dot product

-find angle with acos

oh well.

The fist method works, but damn, I guess I took it too long.

The other functions use even more twisted ways, I'll post them for your amusement when I get back to the code.

But thanks for your interest akb825, it's hard to get people to look at your code, but it helps a lot if someone can tell you more direct techniques to get the results.

Â©hâ‚¬ck Ã¸ut Âµy stuÆ’Æ’ Ã¥t ragdollsoft.com

New game in development Rubber Ninjas - Mac Games Downloads

For your plane line problem, just take the dot product of the line equation and the point, and that's the d part of ax + by + cz = d (where a, b, and c are the vector components of the line). For a plane passing through 3 points, pick a center point, then take the vectors from that point to the other 2 points, take the cross product, and that gives you the normal. Take the dot product like the line and a point problem, and there's your plane. For a line laying on a plane orthogonal to a line, just take the cross product of the plane normal and the line. Just feel free to ask any questions you have on specific problems. That's why we're here!

I used it when it was called WildMagic in my game Rescue. You could check out the Rescue source if you want to see this library in action.

Thanks akb825, though I guess I lost you. Looks like I need to learn the basics of 3d math instead of looking for a 3d library

Â©hâ‚¬ck Ã¸ut Âµy stuÆ’Æ’ Ã¥t ragdollsoft.com

New game in development Rubber Ninjas - Mac Games Downloads

http://www.geocities.com/SiliconValley/2151/math3d.html

Also, you if you're still in school, you might want to take a math class that pertains to the subject. (I know most of what I do with 3D math based on one of my classes in the calculus series I had to take, and I'd probably be pretty lost without the knowledge I gained from it)

So yea, pretty much I love making all my stuff my self. It takes a lot of learning, but its fun to finally have something I WANT to learn about. Not some stuck up teacher trying to cram a book down my throat that is only going to pass through my brain digestive system.

I totally agree about knowing every crook and nanny of your code.