If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Acki
Post
by Acki » Fri Feb 06, 2004 12:52 am
Hi,
my problem is, that I have two 3d-vectors and whant to calculate the distance between them!
With an 2d-vector it's no problem
(Phytagoras: SQR((X2-X1)^2 + (Y2-Y1)^2) = distance
But what about two 3d-vectors ???
Maybe there is a function in Irrlich, that I can use ???
CU, Acki
keless
Posts: 805 Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA
Post
by keless » Fri Feb 06, 2004 1:02 am
irr::core::vector3df difference = vector1 - vector2;
return difference.getLength();
or even simply
return vector1.getDistanceFrom(vector2);
a screen cap is worth 0x100000 DWORDS
DarkWhoppy
Posts: 386 Joined: Thu Sep 25, 2003 12:43 pm
Contact:
Post
by DarkWhoppy » Fri Feb 06, 2004 2:23 am
Oh man i've forgotten about some of the functions of vectors
. But thanks for the reminder keless
(seems my block of code is alittle longer than it should be)
SuryIIID_
Post
by SuryIIID_ » Fri Feb 06, 2004 5:32 pm
With an 2d-vector it's no problem
(Phytagoras: SQR((X2-X1)^2 + (Y2-Y1)^2) = distance
Well you can just add the third element of a 2D vector and make it a 3D vector
SQR((X2-X1)^2 + (Y2-Y1)^2+ (Z2-Z1)^2) = distance ;
PS : No kidding it works
Acki
Post
by Acki » Sat Feb 07, 2004 12:17 am
Thanks !!!
I'll try both methods...
CU