This commit is contained in:
PROFERIS - Mi³osz Stocki
2026-07-08 16:00:57 +02:00
parent eca780df95
commit 349c1aff6f
+6 -2
View File
@@ -69,6 +69,7 @@ const LIMITS = {
// (can never cross to the right side of the box mid-point).
ELBOW_BOX_X_INNER: 5, // ← TUNE: inner X margin from centre for each elbow
ELBOW_BOX_Y_MAX: 50, // ← TUNE: Y below which elbow crossing is forbidden
ELBOW_MIN_Y: 0, // ← TUNE: Y below which the elbow hits the bottom housing/desk
};
// ── Letter / number position lookup table ────────────────────────
@@ -245,13 +246,16 @@ function forward(theta1, theta2) {
*/
function armsCrossed(theta1, theta2) {
const { d2, l1 } = ARM;
const { ELBOW_BOX_X_INNER, ELBOW_BOX_Y_MAX } = LIMITS;
const { ELBOW_BOX_X_INNER, ELBOW_BOX_Y_MAX, ELBOW_MIN_Y } = LIMITS;
const e1x = -d2 + l1 * Math.cos(theta1);
const e1y = l1 * Math.sin(theta1);
const e2x = +d2 + l1 * Math.cos(theta2);
const e2y = l1 * Math.sin(theta2);
// Bottom housing collision
if (e1y < ELBOW_MIN_Y || e2y < ELBOW_MIN_Y) return true;
// E1 (left motor) should not cross to the right side (X > -ELBOW_BOX_X_INNER) if it's low (Y < ELBOW_BOX_Y_MAX)
if (e1y < ELBOW_BOX_Y_MAX && e1x > -ELBOW_BOX_X_INNER) return true;
@@ -269,7 +273,7 @@ function armsCrossed(theta1, theta2) {
* 1. Board outer boundary
* 2. Mechanism housing exclusion box
* 3. IK geometric reachability
* 4. Elbow-crossing guard (prevents physically impossible arm configs)
* 4. Elbow constraints (prevents crossing and hitting the bottom)
*
* @param {number} x
* @param {number} y