Is there a method that returns a unit vector3f that points from one vector to another?
Your question either doesn’t make sense or is trivially done:
Oh yeah, silly me
I have asked this same silly question before , @codex you can use linear interpolation between 2 vectors too with 1.0f scaleFactor ,the linearInterpolation equation idea comes from the slope of the straight line
which indeed gets a
V = 3 i^ + 2 j^ + 1 k^ for example that lies between the specified 2 vectors by a scalefactor , by this equation :
how its done :
Since , Vector0=(x0,y0,z0) , Vector1=(x1,y1,z1);
interPolateX = x0 + (x1-x0)*scaleFactor
interPolateY = y0 + (y1-y0)*scaleFactor
interPolateZ = z0 + (z1-z0)*scaleFactor
So , in jme :
Vector3f interpolatedVec=new Vector3f(); interpolatedVec.interpolateLocal(new Vector3f(0,0,0),new Vector3f(10f,5f,10f),1.0f);
Notice : if you flip the 2 vectors order , you will get an inversed directional vector.
Normalizing a Vector :
if you didn’t normalize your resultant vector , you will get high numbers for distant vectors , normalizing is nothing but dividing each component of Vector3f by the vector magnitude , to reach 1.0f as a resultant vector (V) & its components would represent its direction :
||V|| = sqrt( pow(x,2) + pow(y,2) + pow(z,2)) , which is Pythagorean in nature which is the same as distance formula & Unit Circle equation
normalized V = V^ = ||V||/||V|| = x/||V|| + y/||V|| + z/||V||
So , in jme :
interpolatedVec.normalizeLocal();//normalize & assign the value back to this instance
=> Before solving any vector based problem , break down your vectors into
Vector based Components Vx , Vy , Vz & other operations would be
I didn’t try linear Interpolation, but it should work ,
Yep , it’s an easy operation , but one better understand more why its done , I have been through this recently , so I thought sharing may help , but sometimes it seems it wonot .