Jump to content

Anybody for Some C/C++ Math?

have you had any vector math in school? If you did you can pretty much set up (I am using some translate site now because idk how its called in english sorry) a parametric description of the plane. And because you already know the x and z, it shouldnt be too hard to calculate the y. I recommend writing it out on paper first and then translate it into some code. I could provide pictures of my calculation if you want but I have to go to school first now so it would take a few hours before I can give them to you.

Link to comment
https://linustechtips.com/topic/305300-anybody-for-some-cc-math/#findComment-4149510
Share on other sites

Link to post
Share on other sites

If you know the 3 points A, B and C the equation for a plane can be written as:

 

P(u,v) = A + (B - A)u + (C - A)v

 

which can be broken down into:

 
x = Ax + (Bx - Ax)u + (Cx - Ax)v
y = Ay + (By - Ay)u + (Cy - Ay)v
z = Az + (Bz - Az)u + (Cz - Az)v
 
in those equations, plug in everything you know then use the equations for x and z (system of equations) to calculate the values for u and v, plug them into the equation for y and solve for the answer.

1474412270.2748842

Link to comment
https://linustechtips.com/topic/305300-anybody-for-some-cc-math/#findComment-4149517
Share on other sites

Link to post
Share on other sites

 

If you know the 3 points A, B and C the equation for a plane can be written as:

 

P(u,v) = A + (B - A)u + (C - A)v

 

which can be broken down into:

 
x = Ax + (Bx - Ax)u + (Cx - Ax)v
y = Ay + (By - Ay)u + (Cy - Ay)v
z = Az + (Bz - Az)u + (Cz - Az)v
 
in those equations, plug in everything you know then use the equations for x and z (system of equations) to calculate the values for u and v, plug them into the equation for y and solve for the answer.

 

 

The problem with substition in programming is that there is so many variables that you can't simplify at all so it quite the mess. So if I do take the system of equations and say that the variables that I am solving for are part of the point D. I can solve Dx for 'u' and then plug 'u' into the equation to get Dz and I get something like this: "Dz = Az+((Bz-Az)*(-((Ax+((Cx-Ax)*v)-dX)/(Bx-Ax))))+((Cz-Az)*v)" which it quite the mess. that would need to be solved for 'v' yet and when I did get 'v'. Then I'd have to plug that back into the other eqation to get 'u' which would also be quite the mess.

Link to comment
https://linustechtips.com/topic/305300-anybody-for-some-cc-math/#findComment-4149811
Share on other sites

Link to post
Share on other sites

The problem with substition in programming is that there is so many variables that you can't simplify at all so it quite the mess. So if I do take the system of equations and say that the variables that I am solving for are part of the point D. I can solve Dx for 'u' and then plug 'u' into the equation to get Dz and I get something like this: "Dz = Az+((Bz-Az)*(-((Ax+((Cx-Ax)*v)-dX)/(Bx-Ax))))+((Cz-Az)*v)" which it quite the mess. that would need to be solved for 'v' yet and when I did get 'v'. Then I'd have to plug that back into the other eqation to get 'u' which would also be quite the mess.

Instead of substituting you can use linear algebra to solve for u and v after transforming the equations so matrices

  

|(Bx - Ax), (Cx - Ax) |    |  u  |      | x - Ax |

|(Bz - Az), (Cz - Az) | x |  v   |  = | z - Az |

 

Doing it that way you could at least find some library to do the work for you.

1474412270.2748842

Link to comment
https://linustechtips.com/topic/305300-anybody-for-some-cc-math/#findComment-4149876
Share on other sites

Link to post
Share on other sites

I made a basic calculation on my phone as an example I hope it is clear enough:

 

http://www.mediafire.com/view/81xovlo77x9ecr5/Screenshot_2015-02-06-17-37-09.png

 

with that equation you can calculate the "remaining" x if you already have y and z.  

Link to comment
https://linustechtips.com/topic/305300-anybody-for-some-cc-math/#findComment-4152399
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×