From 4b51b08c455f1c2a42862a8e892c514e5f7a5ce6 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Thu, 19 Oct 2017 21:20:38 +0200 Subject: [PATCH] Simplify the math for better accuracy. --- AVsitter2/Utilities/AVpos-shifter.lsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AVsitter2/Utilities/AVpos-shifter.lsl b/AVsitter2/Utilities/AVpos-shifter.lsl index d17a832..cd714eb 100644 --- a/AVsitter2/Utilities/AVpos-shifter.lsl +++ b/AVsitter2/Utilities/AVpos-shifter.lsl @@ -197,7 +197,7 @@ default data = llGetSubString(data, llSubStringIndex(data, "}") + 1, -1); list parts = llParseStringKeepNulls(data, ["<"], []); vector pos = (vector)("<" + llList2String(parts, 1)); - pos = -target_prim_pos / target_prim_rot + pos / target_prim_rot; + pos = (pos - target_prim_pos) / target_prim_rot; rotation rot = llEuler2Rot((vector)("<" + llList2String(parts, 2)) * DEG_TO_RAD); vector vec_rot = llRot2Euler(rot / target_prim_rot) * RAD_TO_DEG; string result = "<" + FormatFloat(pos.x, 3) + "," + FormatFloat(pos.y, 3) + "," + FormatFloat(pos.z, 3) + ">"; @@ -222,7 +222,7 @@ default { pos = (vector)llList2String(parts, index); rot = llEuler2Rot((vector)llList2String(parts, index + 1) * DEG_TO_RAD); - pos = -target_prim_pos / target_prim_rot + pos / target_prim_rot; + pos = (pos - target_prim_pos) / target_prim_rot; vector vec_rot = llRot2Euler(rot / target_prim_rot) * RAD_TO_DEG; string pos_string = "<" + FormatFloat(pos.x, 3) + "," + FormatFloat(pos.y, 3) + "," + FormatFloat(pos.z, 3) + ">"; string rot_string = "<" + FormatFloat(vec_rot.x, 1) + "," + FormatFloat(vec_rot.y, 1) + "," + FormatFloat(vec_rot.z, 1) + ">";