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:
v2.subtract(v1).normalize()
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
Discussion :
which indeed gets a Vector3f
component 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 :
Interpolation :
Since , Vector0=(x0,y0,z0) , Vector1=(x1,y1,z1);
interPolateX = x0 + (x1-x0)*scaleFactor
interPolateY = y0 + (y1-y0)*scaleFactor
interPolateZ = z0 + (z1-z0)*scaleFactor
new Vector3f(interPolateX,interPolateY,interPolateZ);
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
Conclusion :
=> Before solving any vector based problem , break down your vectors into Vector based Components Vx , Vy , Vz
& other operations would be linear algebra.
I didn’t try linear Interpolation, but it should work ,
Joe asks @Pavl_G “dear sir, what is 1+2?”, @Pavl_G answers, “well… you take the set of all rational and irrational numbers and integrate those from minus infinity to infinity over dt. Hence, e=mc2”
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 .