Group Abstract Group Abstract

Message Boards Message Boards

1
|
3.6K Views
|
8 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Calculation of an angle with 3-4 points in 2 and 3D

Posted 9 years ago

Hello, It may be a silly question but I am looking for a function to do the calculation of an angle between 2 lines. It can be in 2 or 3D and with 3 or 4 points (2 lines not parallel). I tried with something like:

VectorAngle[ {Line[{0, 0}, {1, 0}]}, {Line[{1, 0}, {1, 1}}}} ] 

but it doesn't work ;(

Thank you

POSTED BY: Christophe Nell
8 Replies

Okay, it's only the second day that I use it so I am a bit confused^^ Merci encore M. Huisman pour vos réponses rapides! Bonne fin de journée

POSTED BY: Christophe Nell

Hey, ToExpression works, thanks a lot. I was looking for something like StringToNum as "ToExpression" is not obvious as a fonction for a conversion but it does the job!

POSTED BY: Christophe Nell

It does much more than 'StringToNum', as it does string to everything (equations, formulas, numbers, ....) so rather than having 4-5 different function, Mathematica(Wolfram language) only has one...

POSTED BY: Sander Huisman

Hello Sander, thanks a lot for your advice. With FullForm[...] I find out that there are indeed different. However, I don't know how to force them to be a number as N[...] is not efficient. Any advice?

Attachments:
POSTED BY: Christophe Nell

It looks like you put the wrong character;

N turns (say) Sqrt[2] into 1.4142...

ToExpression forces a string to a number...

try those out, maybe with a combination you can make it work. It seems your starting data is wrong somehow... I never seen such problem...

POSTED BY: Sander Huisman

hey, it looks good, but I still have a small question, because when I write the numbers, it gives me the numerical value, but with a value from my CVS file, it gives me the geometrical expression with ArcCos (see attachement). Somebody know which conversion need to be done? Thank you

Attachments:
POSTED BY: Christophe Nell

Please check if you - is really a minus. Perhaps do FullForm[....] to investigate where the problem is. With a screenshot I can only guess where your typo is... good luck!

Also try N[...] to force everything to be a number...

POSTED BY: Sander Huisman

VectorAngle does not work with 'lines' You have to give it two vectors, something like:

VectorAngle[  {1, 0}-{0, 0},  {1, 1}- {1, 0} ] 

this could be in any dimension, it will assume the the vectors are starting from the origin, and will return the angle between them.

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard