0

Is there a single function or a set of functions that takes two points in 3d space, calculates the distance, and rotates a given radians or degrees?
[example: a plane flies around the equator of a planet, while the planet wobbles relative to the solar system. looking at point the plane is at, using the x,y,z of the solar system. using the center of the planet as (0, 0, 0)]

I have found the function for converting degrees to radians and getting square root for the distance:

import math  
math.radians(1)

math.sqrt(x)

example:

point_1 = [0, 0, 0]
point_2 = [4, 4, 4]

rotation about point_1, rotation 180 degrees or 1 radian would give

point_3 = [-4, -4, -4]
distance = sqtr( ((0-4)(0-4)) + ((0-4)(0-4)) + ((0-4)*(0-4)) )

If Rodrigues' rotation formula can be used, then it needs 2 angles. I would prefer an already made function, but will make my own if I can figure the equation that is needed.

  • Welcome to MSE. Please use MathJax. – José Carlos Santos Jan 22 '18 at 10:15
  • Follow this thread https://stackoverflow.com/questions/6802577/rotation-of-3d-vector – caverac Jan 22 '18 at 10:30
  • "rotates a given radians or degrees?": this has little meaning. Please rephrase. –  Jan 22 '18 at 11:34
  • https://stackoverflow.com/questions/6802577/rotation-of-3d-vector is what i tried before posting in stackoverflow. if v is set to [0,0,0] or [1,1,1] or [2,2,2], the result is v, regardless of theta – Michael Bridges Jan 22 '18 at 23:17
  • i think this explains my error: rotated_v = Quaternion(axis=axis,angle=theta).rotate(v) Assuming v is the point [4,4,4], then axis is between [0,0,0] and [4,4,4]? – Michael Bridges Jan 22 '18 at 23:49
  • Assuming v is the point [4,4,4], then axis is what? The distance is between [0, 0, 0] and [4, 4, 4]. – Michael Bridges Jan 22 '18 at 23:56
  • "google: spherical vs. Cartesian coordinate system transforms ... – Spektre 15 hours ago " was posted on stackoverflow to this question. i did not find a way to private message, and question was deleted. Would someone explain why this is relevant? Why would spherical be considered? – Michael Bridges Jan 23 '18 at 01:41
  • after thinking about converting Cartesian to spherical coordinates, it occurred to me that spherical coordinates has theta which is an angle and can have an angle added to it, however, there is only one new coordinate, and still have the old coordinates to get rho and phi. – Michael Bridges Jan 23 '18 at 09:55
  • actually, rho which is distance, is fixed. maybe after some sleep, i will figure it out – Michael Bridges Jan 23 '18 at 10:11

1 Answers1

1

thanks to Spektre for pointing me in the right direction.

rho which is distance, is fixed. theta and phi are angles, 90 degrees to each other, so of course the angle that does not move is also fixed.

convert from Cartesian to spherical coordinates, move rotate one angle or both, then convert spherical back to Cartesian coordinates