-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SymPy support, and try to solve my LookAt quaternion equation.
- Loading branch information
Showing
8 changed files
with
1,105 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
load("//bzl:rules.bzl", "bazel_lint") | ||
load("//py:rules.bzl", "py_binary") | ||
|
||
py_binary( | ||
name = "ipynb_bin", | ||
srcs = ["__main__.py"], | ||
main = "__main__.py", | ||
visibility = ["//:__subpackages__"], | ||
deps = ["@pip//sympy"], | ||
) | ||
|
||
bazel_lint( | ||
name = "bazel_lint", | ||
srcs = ["BUILD.bazel"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from sympy import Quaternion, solve, symbols, Eq | ||
|
||
centre = Quaternion(0, *symbols('c_i c_j c_k', real=True)) | ||
|
||
# vector from centre upward | ||
up = Quaternion(0, *symbols('u_i u_j u_k', real=True)) | ||
|
||
forward = Quaternion(0, *symbols('fw_i fw_j fw_k', real=True)) | ||
|
||
r_w, r_i, r_j, r_k = symbols('r_w r_i r_j r_k', real=True) | ||
|
||
rotation = Quaternion(r_w, r_i, r_j, r_k) | ||
|
||
look_at = Quaternion(0, *symbols('la_i la_j la_k', real=True)) | ||
|
||
centre_does_not_rotate = Eq(centre * rotation, centre) | ||
|
||
forward_will_look_at = Eq( | ||
((centre - forward) * rotation).normalize(), | ||
(centre - look_at).normalize() | ||
) | ||
|
||
length_of_forward_unchanged = Eq( | ||
(forward-centre).norm(), | ||
((forward * rotation) - centre).norm() | ||
) | ||
|
||
up_will_still_be_up = Eq( | ||
(up * rotation), | ||
up | ||
) | ||
|
||
solve( | ||
[ | ||
length_of_forward_unchanged, | ||
centre_does_not_rotate, | ||
forward_will_look_at, | ||
up_will_still_be_up | ||
], [ | ||
r_w, r_i, r_j, r_k | ||
] | ||
) |
Oops, something went wrong.