-1

It is probably really simple, but I have checked everywhere and it still doesn't work for me. How do you fine the angle between two lines. Lets say we have two line:

with(LinearAlgebra): x:=Line([0,0],[2,0]): y:=Line([2,0],[2,2]):

How do I find the angle between these two lines. I know the angle is 90 degrees, this is just a simple example so I know the notation and apply it to harder examples.

Jerry
  • 29
  • 5

1 Answers1

1

You can use the following formula:

a.b/(Norm(a)*Norm(b) = cos(theta)

where theta is angle between vector a and vector b.

I'm not aware of a Line function in the LinearAlgebra package. But you can use a vector:

x:=<2;0>;
y:=<0;2>;

The dotproduct can be calculated with the function DotProduct, and the norm with Norm (both in LinearAlgebra), which leads to:

arccos(DotProduct(x, y)/(Norm(x, 2)*Norm(y, 2)))
ViG
  • 1,848
  • 1
  • 11
  • 13
  • Thank you very much, this is very useful. Last thing, is there a way to actually do it with lines. I've tried this but it doesn't work. with(Student[MultivariateCalculus]): l1≔Line([0,0,0],⟨1,2,4⟩): l2≔Line([1,1,2],⟨2,3,0⟩): Angle(l1,l2); Error, invalid input: Student:-MultivariateCalculus:-Angle expects its 1st argument, x, to be of type {Student:-MultivariateCalculus:-Line, Student:-MultivariateCalculus:-Plane, Vector}, but received l1 I keep getting this error. Here is the link I use, https://www.maplesoft.com/support/help/Maple/view.aspx?path=Student%2FMultivariateCalculus%2FAngle – Jerry Mar 06 '18 at 12:01
  • @Jerry Normally you should be able to do it with `x:=Line([0,0],[2,0]): y:=Line([2,0],[2,2]):` like you defined in your question. – ViG Mar 06 '18 at 16:51