As a first guess:
your problem starts with line 61
$Nullframe is write protected (actually you should get error messages)
No, of course, I am not trying to overwrite the system variable $Nullframe
Line 61 simply initiates my FRAME variable with null values. Although to tell you the truth, this is unnecessary in this code.
How is this intended to work? Are you placing the Origin of the Base at the start of the weld, and simply calculating from there to the endpoint? It looks like you're trying to set the X axis of Base 32 to be the vector of the weld, correct?
Does this error occur in all quadrants? If this is a trigonemetry issue, running it in all 4 quadrants (45deg, 135deg, 225deg, 315deg) might reveal something.
Yes, that's the logic.
I place the origin of the coordinates at the starting point of the weld, align the X-axis of base 32 with the vector of the weld and simply increase the X value to weld the required number of weld segments.
In this case, the wrong direction does not occur in all quarters of the coordinate system.
But I don't think it's trigonometry or linear algebra problem - in my excel the calculations are correct. And if you transfer the resulting coordinates to KUKA SimPro, they are exactly the same as I thought they would be.
Think the problem is using ACOS().
This function leads to loosing the sign of the angle.
Use atan2 with the difference of x and y coordinates instead of x and length of hypothenuse.
Yeah! It's very much like the truth!
I thought about the possibility of losing a sign somewhere but couldn't see how that was possible.
I will try to implement alternative logic.
Thanks to all of you guys!