MathInspector / MathInspector

A visual programing environment for scientific computing with python
GNU General Public License v3.0
894 stars 64 forks source link

Non-standard camera orientation in 3D #40

Open EtienneDesticourt opened 3 years ago

EtienneDesticourt commented 3 years ago

Hi,

From the 3D software I have used there are two standard options for axes orientation:

A) x points to the right, y points up z points towards the camera

B) x points towards the camera y points to the right z points up

Currently the camera is oriented so that x points towards the camera y points up z points to the left <- problematic for positive values of z which we interpret naturally as negative in this orientation

Cheers

MathInspector commented 3 years ago

Good call. I want to use (B). In every math book I have, the z-axis points up for 3d plots, and I have been trying to get the z-axis to point up for awhile, and keep getting stuck.

On this line, it does the following :

self.model = glm.rotate(self.model, glm.radians(-90.0), glm.vec3(0,1,0))

https://github.com/MathInspector/MathInspector/blob/master/mathinspector/plot/plot3d.py#L49

But whenever I rotate things so the z-axis points up, all the controls get messed up. I would really like to get this fixed so z is up. Do you have any idea's what to change to get that? I have been taking shots at it every so often and haven't been able to figure it out.

EtienneDesticourt commented 3 years ago
self.camera_up = glm.vec3(0,0,1)
self.model = glm.rotate(self.model, glm.radians(90.0), glm.vec3(0,0,1))

Should do the trick

MathInspector commented 3 years ago

SWEET! Thank youuu =)

Will add this to the upcoming PR after the new release of 0.9.4

Do you know how to fix the gimble lock? I can't seem to look up properly =(

I think the solution is to use quaternions but I am kind of n00b at quaternions and have been too busy to fix the gimble lock issue. lmk if you have any advice about that. Thanks.