This is probably the wrong place to post but i was to lazy to sign up on a math forum and i thought id might get mist response here…
So my problem:
I have a 2D array, read out of a terrain (the getheights())
I also have a 3D vector where i have the x and z coordinate and i want to get the y coordinate from the array…
Since a 2D array requires integers i round the vectors x and z coordinate so i have a point in the array and i take out a 2nd (rounded x + 1) and a 3rd (rounded z + 1) out of the array
Now from these 3 points i want to get the y coordinate of the vector between those three…
Im really stuck on this question please help me guys
Btw: i cant use getheight() since i want to code this in java (real java not javascript) and i already read in the terrain heights
The cross product of any two vectors gives a third vector perpendicular to the plane the two vectors reside in. How you do the calculation matters x X z gives one direction z X x gives the negative 180 degree offset vector.
You can interpolate lots of data (Vectors, Quaternions, Floats, Ints, etc).
A good example of a spherical interpolation is let’s say you have an enemy heading towards the player by X amount of time, you’ll do like so (pseudo code) :
desiredRotation = Quaternion.Euler (enemyTransform.position - playerTransform.position);//get the player direction
enemyTransform.rotation = Quaternion.Slerp(enemyTransform.rotation, desiredRotation, rotateSpeed * Time.deltaTime);
From there, you can do the same with Lerp (only linear), on Vectors, etc.
I’m just giving an example to Robblie of one of the many ways to interpolate values in Unity.
You should provably stop making no sense comments and post something useful.
I’m leaving it here, have a nice day.
I’ve modified my first post to fix my lack of reading attention regarding the Java part. ← Idiot face!
However my interpolation example with Quaternions still valid. ^^