Skip to content

Instantly share code, notes, and snippets.

@chenyong chenyong/rotate.js
Created Apr 9, 2018

Embed
What would you like to do?
Some math to explore 3D rotation, find the center point of the orbit.
axie = k1 * (x*i + y*j + z*k)
point = a*i + b*j + c*k
distance = (k1*x - a)*i + (k1*y - b)*j + (k1*z - c)*k
0 = axie * distance = k1 * (x*i + y*j + z*k) * ((k1*x - a)*i + (k1*y - b)*i + (k1*z - c)k)
0 = (x*i + y*j + z*k) * ((k1*x - a)*i + (k1*y - b)*i + (k1*z - c)k)
= (x*i) * ((k1*x - a)*i + (k1*y - b)*j + (k1*z - c)k)
+ y*j * ((k1*x - a)*i + (k1*y - b)*j + (k1*z - c)k)
+ z*k * ((k1*x - a)*i + (k1*y - b)*j + (k1*z - c)k)
= ((k1*x - a)*x*i + (k1*y - b)*x*j + (k1*z - c)*x*k)i
+ ((k1*x - a)*y*i + (k1*y - b)*y*j + (k1*z - c)*y*k)j
+ ((k1*x - a)*z*i + (k1*y - b)*z*j + (k1*z - c)*z*k)k
= (-(k1*x - a)*x - (k1*y - b)*x*k + (k1*z - c)*x*j)
+ ((k1*x - a)*y*k - (k1*y - b)*y - (k1*z - c)*y*i)
+ (-(k1*x - a)*z*j + (k1*y - b)*z*i - (k1*z - c)*z)
= - (k1*x - a)*x - (k1*y - b)*y - (k1*z - c)*z
+ (k1*y - b)*z*i - (k1*z - c)*y*i
+ (k1*z - c)*x*j - (k1*x - a)*z*j
+ (k1*x - a)*y*k - (k1*y - b)*x*k
0 = - (k1*x - a)*x - (k1*y - b)*y - (k1*z - c)*z
= - k1*x^2 + a*x - k1*y^2 + b*y - k1*z^2 + c*z
= k1(- x^2 - y^2 - z^2) + a*x + b*y + c*z
k1 = (a*x + b*y + c*z)/(x^2 + y^2 + z^2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.