Hi All,
I have couple of questions. part of my code is acting really weirdly,
in PositionMatrix translation I have no clue where Length (106.0666) is coming from.
X is fine though it should show 75 instead of 74.99999
again I don't know where -75 is coming from as Y-axis value.
Best regards,
sam
Solved! Go to Solution.
Solved by alewer. Go to Solution.
@sam wrote:in PositionMatrix translation I have no clue where Length (106.0666) is coming from.
The length is expected for the values of X, Y, and Z. You can think of the length as the distance from (0, 0, 0) to (75, -75, 0). By pythagorean theorem this is sqrt(75^2+75^2)=106.066, so my math agrees with Inventor's.
@sam wrote:X is fine though it should show 75 instead of 74.99999
This can come from a number of places... floating point binary representations of numbers are imperfect and lead to rounding errors, some of which are not exactly obvious. For example in base 10 we know that some numbers do not have exact representations--for example 1/3 = 0.333... and there is no way to exactly represent this number as a decimal. With binary representations, 1/10 suffers from the same problem--it is a repeating decimal with no exact representation. As a result of this (and other oddities of binary floating point math), you will often see rounding errors that you might not expect. Well written software usually tries to hide this weirdness from the user, but since you are in API land, none of this will be hidden from you.
@sam wrote:again I don't know where -75 is coming from as Y-axis value.
Have a look at this excellent document (handout from Brian Ekins' 2008 AU presentation How Deep is the Rabbit Hole?) https://modthemachine.typepad.com/files/mathgeometry.pdf
If you read the document and still have questions, I suggest sharing your code. There is very little I can do to help with just a screenshot of a couple lines.
One more point about X=74.99999: another look at your code and your error ths could also easily come from what appears to be a rather inexact approximation of pi. Try using 2 * Math.Atn(1) instead of 3.14159... / 2.
@alewer Thank you so very for taking time to explain and that article is brilliant. I have just printed it and will read it thoroughly on weekend, it is brilliant and explains the topic much better and in detail than what is available on Inv help for same topic.
I just need to clarify one more thing, if you look at my few lines of code you would note (and might agree) that in those few lines not even once I have given/assigned any value to Y, then why and where the value of Y might be coming from (and that too exactly 75).
Thank you so much again and have a great weekend.
regards,
sam
@alewer wrote:One more point about X=74.99999: another look at your code and your error ths could also easily come from what appears to be a rather inexact approximation of pi. Try using 2 * Math.Atn(1) instead of 3.14159... / 2.
I have tried this and its not same, isn't it?
Can't find what you're looking for? Ask the community or share your knowledge.