-
-
Notifications
You must be signed in to change notification settings - Fork 23
Current rotation fixes #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,22 +55,22 @@ | |
| (chan-fx/apply-channel-value buffers c tilt)) | ||
| (swap! (:movement *show*) #(assoc-in % [:current direction-key] [pan tilt])))) | ||
|
|
||
| (defn current-rotation | ||
| (defn current-rotation ;XXX just store the rotations instead - this will always be slower and sometimes solutions will vary... | ||
| "Given a head and DMX pan and tilt values, calculate a | ||
| transformation that represents the current orientation of the head | ||
| as compared to the default orientation of facing directly towards | ||
| the positive Z axis." | ||
| [head pan tilt] | ||
| (let [rotation (Transform3D. (:rotation head))] | ||
| (when-let [pan-scale (:pan-half-circle head)] | ||
| (let [dmx-pan (/ (- pan (:pan-center head)) pan-scale) | ||
| (let [pan-half-rotations (/ (- pan (:pan-center head)) pan-scale) | ||
| adjust (Transform3D.)] | ||
| (.rotY adjust (* Math/PI dmx-pan)) | ||
| (.rotY adjust (* Math/PI 0.5 pan-half-rotations)) | ||
| (.mul rotation adjust))) | ||
| (when-let [tilt-scale (:tilt-half-circle head)] | ||
| (let [dmx-tilt (/ (- tilt (:tilt-center head) tilt-scale)) | ||
| (let [tilt-half-rotations (/ (- tilt (:tilt-center head)) tilt-scale) | ||
| adjust (Transform3D.)] | ||
| (.rotX adjust (* Math/PI dmx-tilt)) | ||
| (.rotX adjust (* Math/PI 0.5 tilt-half-rotations)) | ||
|
||
| (.mul rotation adjust))) | ||
| rotation)) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The multiplication by 0.5 appears to be incorrect. The variable
pan-half-rotationsalready represents the number of half-circles (180-degree units), where one half-circle equals π radians. Therefore, the conversion to radians should beMath/PI * pan-half-rotations, notMath/PI * 0.5 * pan-half-rotations.This can be verified by examining the inverse calculation in
angle-to-dmx-valuein transform.clj (line 229), which uses the formula:center-value + (angle / Math/PI) * half-circle-value. Rearranging this gives:angle = ((dmx - center) / half-circle-value) * Math/PI, which matches what the variable name suggests but contradicts the current implementation.With the current code, a fixture will only rotate to half the intended angle.