Java2D build "lookAt" funktion for 3DPoints.

Hello!

I have here -> http://88.192.212.114

My Java2D engine for my AWT 3D games, this is what im asking now.
My AWT 3D engine for my site, is almost done, but, i now need some tiny help with one funktion,
the funktion where i need this help is “AWT.lookAt( Point3D p3a, Point3D p3b );”

I currently have the following code to do rotation to certain Point3D(x,y,z);


if ( JC.keys[KeyEvent.VK_L])
{
       	double xa = JMath.calcAngle ( new Point ( (int)AWT.eye_ypos, (int)AWT.eye_zpos), new Point(0,0) );
      	double ya = JMath.calcAngle ( new Point ( (int)AWT.eye_xpos, (int)AWT.eye_zpos), new Point(0,0) );
      	double za = JMath.calcAngle ( new Point ( (int)AWT.eye_xpos, (int)AWT.eye_ypos), new Point(0,0) );
            		 
      	AWT.rotate3DTo ( xa , ya , za );
}

eye_(xyz)pos is the location of camera, and the camera is looking to the Point3D (0,0,0);

The rotate3DTo ( xa,ya,za); rotates camera to look to selected angles.
When running code, I have success on y angle and some with x angle but when i change eye_zpos, then the look wont give right angles anymore.
I have tryed to look google and i have found several tutorials, but, they have been too difficult for me to follow.

Maybe some of here have some old lookAt tutorial on storage to help me !

//----

Thanks,

nice :slight_smile:

you only need to compute xa and ya :

assuming that the camera pos is xe,ye,ze solution is something like this :

double distXZ=Math.sqrt(xexe+zeze);
xa=(+/-)Math.atan(ye/distXZ);
ya=(+/-)Math.atan(xe/ze);

this is an incomplete & fast answer but it is probably a good starting point that can help you, it compute angle from location 0,0,0 to object at xe,ye,ze

LookAt!

Great, i now have an working AWT.lookAt ( Point3D , Point3D ); funktion on my 3D library, this was a great help, great !!

It is my first 3D engine this what im now creating,
i dont know if i really need this following bit on my project, but, would like to ask anyway,
what about an polygon airplane flying on 3D world, how about the rotating of plane nose and screen view around.

Is there just as simple formulas for airplane nose 3D rotatings and forward movings, as the formulas what i just received with lookAt question ??

//----

Thanks,