Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/afterglow/effects/movement.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link

Copilot AI Dec 20, 2025

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-rotations already represents the number of half-circles (180-degree units), where one half-circle equals π radians. Therefore, the conversion to radians should be Math/PI * pan-half-rotations, not Math/PI * 0.5 * pan-half-rotations.

This can be verified by examining the inverse calculation in angle-to-dmx-value in 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.

Copilot uses AI. Check for mistakes.
(.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))
Copy link

Copilot AI Dec 20, 2025

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 tilt-half-rotations already represents the number of half-circles (180-degree units), where one half-circle equals π radians. Therefore, the conversion to radians should be Math/PI * tilt-half-rotations, not Math/PI * 0.5 * tilt-half-rotations.

This can be verified by examining the inverse calculation in angle-to-dmx-value in 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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm might have had some other thing that was causing end result angles to be off then... will investigate

(.mul rotation adjust)))
rotation))

Expand Down