Search code examples
anglemaple

Angles between two lines in maple


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.


Solution

  • 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)))