How do I create the equivalent of basis.z?
Asked Answered
A

2

0

Say that i want to convert my X rotation and Y rotation into a position in that direction.

This is how to translate my ship.position in the direction it is pointed with Transform3D:

	ship.rotation_degrees.y = ry
	ship.rotation_degrees.x = rx
	
	var t = Transform3D()
	t = t.rotated_local(Vector3(0,1,0), deg_to_rad(ry))
	t = t.rotated_local(Vector3(1,0,0), deg_to_rad(rx))
	ship.position = t.basis.z * radius

In a parallel universe where Transform3D didn't exist, how would I do the same thing without it?
here is my failed attempt at doing so, I can only get one rotation to work at a time:

	ry = deg_to_rad(ry)
	rx = deg_to_rad(rx)
	ship.position = Vector3(sin(ry),sin(-rx),cos(ry-rx))*radius

I'm not sure how to combine the yz(rx) and the xz(ry) translation values;
t.basis.z is only equal to Vector3(sin(ry),sin(-rx),cos(ry-rx)) when either rx or ry are 0, otherwise they are not aligned.

I'm a bit lost on how I am supposed to do this without making it overly complicated.

Ashton answered 16/2 at 3:51 Comment(0)
A
0

Ashton What's your actual goal with this?

Atlantes answered 16/2 at 14:11 Comment(0)
A
0

Atlantes creating shorter code.
Though from the looks of it, combining yz and xz is more complicated than just using Basis. so nvm.

Ashton answered 20/2 at 1:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.