Message Boards Message Boards


Calculate distance between two points?

Posted 3 years ago
4 Replies
1 Total Likes

Hi there,

I wrote a code and used the function possibility in order to make the code more lean, however it seems that the function functionality makes the thing not work.

Mathematica code and output

I computed the same equation in Excel and get the same answer as the final result of the Mathematica code

enter image description here

Help would be much appreciated. Not sure what I do wrong within the programming now. I somewhat assume the use of Degree inside the function might cause some trouble, but help is appreciated as mentioned before. Ah and just realised, the screenshot doesn't include the definition of rroller and wgap in Mathematica, but they are as such: wgap = 0.0005 ;(gap width in meters) rroller = 0.1; (roller radius in meters)

Cheers, Eric

4 Replies


Mathematica uses radians, not degrees. You can either convert to radians (2 Pi/360). You can also use units but to do that you should use

Quantity[40, “degrees”]

(I am not in front of my machine so I believe degrees is lowercase and plural but I could be wrong - look it up)



Posted 3 years ago

Hi Neil,

thanks for your response. With the capital letter Degree behind the number it should work fine as it converts the input of degree into radian automatically, as indicated with my tests of every step along the computation. I didn't know that I can incorporate units with Quantify so far. Thank you very much for that.

It should work though, that's the confusing part for me, but if it won't work I'll have to separate the part and just feed the value in radians. I'll see.

Thanks, Eric

Posted 3 years ago

Hi everyone,

okay apparently the Degree in the function definition is something Mathematica doesn't like. Just got rid of that and put the Degree to the input value and it works fine and computes the correct value.

I am still curious for the underlying assumption though. Because I wanted to make sure that it is always correct and I wouldn't forget it so I put the degree in the function instead of every input. If anyone has an idea what the thinking behind this issue is, please let me know.

Cheers, Eric

Posted 3 years ago

Hi Eric

At first glance I have not found where the fault is in your code, I did it a moment ago and got good results, please see the image below. resuelto

I could not reproduce the results that you show and it would be better if you shared your code to be able to review it in more detail, since the code can not be copied from the image. I share the notebook where I obtained the results that I showed in the image. I hope this will help you solve your doubts.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract