I’m on the right way???
vec = Vector((0,1,0))
q = vec.to_track_quat(“Y”,“Z”)
eu = q.to_euler()
??
I’m on the right way???
vec = Vector((0,1,0))
q = vec.to_track_quat(“Y”,“Z”)
eu = q.to_euler()
??
Let me riformulate your question in 3 different ways:
given a vector V = Vector([Vx, Vy, Vz]):
“find a sequence of euler rotations that brings the world x-axis aligned to it”.
Answer #x:
psi = arctan(Vy/Vx); teta = -arcsin(Vz/V.length); fi = undetermined (zero is appropriate)
“find a sequence of euler rotations that brings the world y-axis aligned to it”.
Answer #y:
psi = -arctan(Vx/Vy); teta = undetermined (zero is appropriate); fi = arcsin(Vz/V.length)
“find a sequence of euler rotations that brings the world z-axis aligned to it”
Answer #z:
psi= arctan(Vy/Vx); teta = arccos(Vz/V.length); fi = 0.
Please note that none of the above answer is unique!
For what do you need angles?
where is “arctan”? :spin:
if make with atan say :
Traceback (most recent call last):
File “<blender_console>”, line 1, in <module>
ZeroDivisionError: float division by zero
in the module math not see arctan and even arcsin
what module is?
many time happen this situation and , I know how solve but I think which is not the best way…
we say which there player (A) and enemy(B) and I know yours position , I want have the camera which see ever the player to left and the enemy to right. (from a distance predefinited)
how make?(not valid using empty )
# suggested imports:
from math import sin, cos, tan, atan2, asin, acos, degrees, radians
# Then, in the above formulas:
# use atan2(b,a) for arctan(b/a)
# use asin() for arcsin()
# use acos() for arcos()
Sorry, I don’t understand the specific problem you sketched above.
I know exactly your problem. It’s not all that hard to solve. Simply get a vector between person A and person B.
Get the midpoint of that vector, and have the camera at a point on the vector that is perpendicular to this point.
then, moving the camera forwards and backwards, or changing the lens attribute will allow you to keep both players on screen.
I probably not have put all information , but because , really is difficult to me understand the rotation .
anyway, this (atan, asin) I know thanks
this sound as my solution , (in part)
. Simply get a vector between person A and person B.
yes
Get the midpoint of that vector,
yes
and have the camera at a point on the vector that is perpendicular to this point.
how this? how make to have the cam perpendicular??
by chance :
alignAxisToVect([0,0,1],1,1)
alignAxisToVect((enemy.position-player.position)*-1,2,1)
applyMovement((0,20,20),1)
?
EDIT:
plus
cam.alignAxisToVect([0,0,1],1,1)
vec=cam.getVectTo(midPoint)
cam.alignAxisToVect(vec[1]*-1,2,1)
now is right
as minimum I make 80% of calculation usenless…
Here is the example. although you may not need the maths behind it, it’s useful to know.
cross.blend (120 KB)
i mean , I have one vector(enemy-player)
we say which I need of the same vector , but rotate by 45°
but how make if not know the eurler of vector? for thath my question
Same example blend:
import bge
import mathutils
import math
def point_between(cont):
own = cont.owner
scene = bge.logic.getCurrentScene()
a = scene.objects['Empty'].worldPosition
o = own.worldPosition
o_a = a - o
rotation = mathutils.Matrix.Rotation(math.radians(-90.0), 4, 'Z')
rotated_vector = rotation * o_a
bge.render.drawLine(o, o+o_a, [1, 1, 1])
bge.render.drawLine(o, o+rotated_vector, [1, 0, 1])
thanks agoose!!! cool!!
this seem what I need!!! thanks!!!