just a little while ago, with this almost completely typed out, I found a blender tutorial, here:

http://luma.co.za/labs/

which works well enough, and I was able to mod it to use a custom vector for direction (quickly tested), but I really would like to do it without the extra empty that one has to parent to the camera, but if it solves the issues, then I am willing to call it good enough. But a bigger problem was that I am not sure how to get the rotation matrix to apply without the “setOrientation” class outside of the game engine :o

= = = = = =

So, onto what I had originally come here for.

This all started in regards to this thread:

http://blenderartists.org/forum/showthread.php?t=86971

basically, the camera or any other object seems to flip at certain points which I would like to get around. It seems to stem from the inability to define an “up” for the 'track to constraint. :mad:

I have worked on some code, but I have gotten a little confused with the 3d math … I have been reading about how this is done, using this problem as a learning experience; eg

http://www.gamedev.net/reference/articles/article695.asp

I ended up making a sketch to organize my thoughts,and prettied it up for you all …

red = points/locations

orange = vectors (where a vector from pointA to pointB => AB (with vector symbol thingy over it)

puple = vectors, which are axis for the camera

basically, I think I have enough info to solve the problem, but it just isn’t coming out and I don’t know what results to expect in intermediate steps to be able to really debug it.

here is a snipet of my code, cleaned up and with some added comments:

```
#S0 = 0,0,0 = origin
# Ct, P1, S1 locations (x, y, z) are given which gives the vectors:
# vecS0_Ct
# vecS0_P1
# vecS0_S1
vecS1_Ct = vecS0_S1 - vecS0_Ct
vecS1_P1 = vecS0_S1 - vecS0_P1
vecP1_Ct = vecS1_P1 - vecS1_Ct
vecSP = CrossVecs( vecS1_P1.normalize(), vecP1_Ct..normalize() )
vecThrd = CrossVecs( vecSp.normalize(), vecP1_Ct.normalize() )
C = -vecP1_Ct
B = vecSP
A = vecThrd
matCam= Mathutils.Matrix(
[ A[0], B[0], C[0], 0 ]
[ A[1], B[1], C[1], 0 ]
[ A[2], B[2], C[2], 0 ]
[ 0 0 0 1 ])
rotCam = matCam.toEuler()
```

What I am doing is taking the given points which allows me to find some vectors, wherby the direction between P1 and Ct will define the -z axis, and the normal of the plane (light blue) will define the x, the y being the cross product of the two. As I understand, with those vectors, I can create the rotation matrix and then finally I am able to get the eulers for the camera.

Unfortunately, it doesn’t work. I know I must be doing some things quite wrong because the results are seemingly random. :o since Ct and be the same as S1, I know I need to make some changes to allow for this, but at the moment that seems minor compared to getting the math to come out.