Magnitude of Line

Post any maths and/or physics related questions here.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Magnitude of Line

Postby Invictus » Sun Nov 28, 2004 1:27 am

What is the formula to get the magnitude of a line?? The distance between two 3d points.
User avatar
Invictus
 
Posts: 3054
Joined: Tue Oct 21, 2003 12:59 pm

Postby Beer Hunter » Sun Nov 28, 2004 1:40 am

Given points u and v that define the ends of the line-segment, set d = uv. The length is simply sqrt(d.x*d.x + d.y*d.y + d.z*d.z). Same idea with any number of dimensions.
User avatar
Beer Hunter
 
Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

Postby Invictus » Sun Nov 28, 2004 2:00 am

Thanks! I should have known that.
Code: Select all
float Vertex::GetMagnitude(Vertex b)
{
   Vertex tmp;
   tmp.x = x - b.x;
   tmp.y = y - b.y;
   tmp.z = z - b.z;
   return sqrt(tmp.x*tmp.x + tmp.y*tmp.y + tmp.z*tmp.z);
}
User avatar
Invictus
 
Posts: 3054
Joined: Tue Oct 21, 2003 12:59 pm


Return to Maths & Physics

Who is online

Users browsing this forum: No registered users and 1 guest