Skip to main content
added 4 characters in body
Source Link
Black
  • 20k
  • 45
  • 183
  • 292

Pictures say more then thousand words. As you can see in my screenshot i try to calculate the angle between the coordinates AB and BC, in this case the angle is obviously 90°. But how can i determine this angle with javascript code?

I try to determine the angle between AB and BC

I found this thread and tried the accepted solution, but i always get 1.57instead of 90 like i expected. I rewrote the original function because i did not understood how to pass my parameters to it.

Please excuse my bad paint and math skills.

    function find_angle(Ax,Ay,Bx,By,Cx,Cy)
    {
        var AB = Math.sqrt(Math.pow(Bx-Ax,2)    +   Math.pow(By-Ay,2));    
        var BC = Math.sqrt(Math.pow(Bx-Cx,2)    +   Math.pow(By-Cy,2)); 
        var AC = Math.sqrt(Math.pow(Cx-Ax,2)    +   Math.pow(Cy-Ay,2));
        
        return Math.acos((BC*BC+AB*AB-AC*AC)    /   (2*BC*AB));
    }
    var angle = find_angle
                (
                    4 ,     //Ax
                    3 ,     //Ay
                    
                    4 ,     //Bx
                    2 ,     //By
                    
                    0 ,     //Cx
                    2       //Cy
                )
                
    alert ( angle );

I try to determine the angle between AB and BC

Pictures say more then thousand words. As you can see in my screenshot i try to calculate the angle between the coordinates AB and BC, in this case the angle is obviously 90°. But how can i determine this angle with javascript code?

I found this thread and tried the accepted solution, but i always get 1.57instead of 90 like i expected. I rewrote the original function because i did not understood how to pass my parameters to it.

Please excuse my bad paint and math skills.

    function find_angle(Ax,Ay,Bx,By,Cx,Cy)
    {
        var AB = Math.sqrt(Math.pow(Bx-Ax,2)    +   Math.pow(By-Ay,2));    
        var BC = Math.sqrt(Math.pow(Bx-Cx,2)    +   Math.pow(By-Cy,2)); 
        var AC = Math.sqrt(Math.pow(Cx-Ax,2)    +   Math.pow(Cy-Ay,2));
        
        return Math.acos((BC*BC+AB*AB-AC*AC)    /   (2*BC*AB));
    }
    var angle = find_angle
                (
                    4 ,     //Ax
                    3 ,     //Ay
                    
                    4 ,     //Bx
                    2 ,     //By
                    
                    0 ,     //Cx
                    2       //Cy
                )
                
    alert ( angle );

I try to determine the angle between AB and BC

As you can see in my screenshot i try to calculate the angle between the coordinates AB and BC, in this case the angle is obviously 90°. But how can i determine this angle with javascript code?

I try to determine the angle between AB and BC

I found this thread and tried the accepted solution, but i always get 1.57instead of 90 like i expected. I rewrote the original function because i did not understood how to pass my parameters to it.

Please excuse my bad paint and math skills.

    function find_angle(Ax,Ay,Bx,By,Cx,Cy)
    {
        var AB = Math.sqrt(Math.pow(Bx-Ax,2)    +   Math.pow(By-Ay,2));    
        var BC = Math.sqrt(Math.pow(Bx-Cx,2)    +   Math.pow(By-Cy,2)); 
        var AC = Math.sqrt(Math.pow(Cx-Ax,2)    +   Math.pow(Cy-Ay,2));
        
        return Math.acos((BC*BC+AB*AB-AC*AC)    /   (2*BC*AB));
    }
    var angle = find_angle
                (
                    4 ,     //Ax
                    3 ,     //Ay
                    
                    4 ,     //Bx
                    2 ,     //By
                    
                    0 ,     //Cx
                    2       //Cy
                )
                
    alert ( angle );

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Pictures say more then thousand words. As you can see in my screenshot i try to calculate the angle between the coordinates AB and BC, in this case the angle is obviously 90°. But how can i determine this angle with javascript code?

I found this threadthread and tried the accepted solution, but i always get 1.57instead of 90 like i expected. I rewrote the original function because i did not understood how to pass my parameters to it.

Please excuse my bad paint and math skills.

    function find_angle(Ax,Ay,Bx,By,Cx,Cy)
    {
        var AB = Math.sqrt(Math.pow(Bx-Ax,2)    +   Math.pow(By-Ay,2));    
        var BC = Math.sqrt(Math.pow(Bx-Cx,2)    +   Math.pow(By-Cy,2)); 
        var AC = Math.sqrt(Math.pow(Cx-Ax,2)    +   Math.pow(Cy-Ay,2));
        
        return Math.acos((BC*BC+AB*AB-AC*AC)    /   (2*BC*AB));
    }
    var angle = find_angle
                (
                    4 ,     //Ax
                    3 ,     //Ay
                    
                    4 ,     //Bx
                    2 ,     //By
                    
                    0 ,     //Cx
                    2       //Cy
                )
                
    alert ( angle );

I try to determine the angle between AB and BC

Pictures say more then thousand words. As you can see in my screenshot i try to calculate the angle between the coordinates AB and BC, in this case the angle is obviously 90°. But how can i determine this angle with javascript code?

I found this thread and tried the accepted solution, but i always get 1.57instead of 90 like i expected. I rewrote the original function because i did not understood how to pass my parameters to it.

Please excuse my bad paint and math skills.

    function find_angle(Ax,Ay,Bx,By,Cx,Cy)
    {
        var AB = Math.sqrt(Math.pow(Bx-Ax,2)    +   Math.pow(By-Ay,2));    
        var BC = Math.sqrt(Math.pow(Bx-Cx,2)    +   Math.pow(By-Cy,2)); 
        var AC = Math.sqrt(Math.pow(Cx-Ax,2)    +   Math.pow(Cy-Ay,2));
        
        return Math.acos((BC*BC+AB*AB-AC*AC)    /   (2*BC*AB));
    }
    var angle = find_angle
                (
                    4 ,     //Ax
                    3 ,     //Ay
                    
                    4 ,     //Bx
                    2 ,     //By
                    
                    0 ,     //Cx
                    2       //Cy
                )
                
    alert ( angle );

I try to determine the angle between AB and BC

Pictures say more then thousand words. As you can see in my screenshot i try to calculate the angle between the coordinates AB and BC, in this case the angle is obviously 90°. But how can i determine this angle with javascript code?

I found this thread and tried the accepted solution, but i always get 1.57instead of 90 like i expected. I rewrote the original function because i did not understood how to pass my parameters to it.

Please excuse my bad paint and math skills.

    function find_angle(Ax,Ay,Bx,By,Cx,Cy)
    {
        var AB = Math.sqrt(Math.pow(Bx-Ax,2)    +   Math.pow(By-Ay,2));    
        var BC = Math.sqrt(Math.pow(Bx-Cx,2)    +   Math.pow(By-Cy,2)); 
        var AC = Math.sqrt(Math.pow(Cx-Ax,2)    +   Math.pow(Cy-Ay,2));
        
        return Math.acos((BC*BC+AB*AB-AC*AC)    /   (2*BC*AB));
    }
    var angle = find_angle
                (
                    4 ,     //Ax
                    3 ,     //Ay
                    
                    4 ,     //Bx
                    2 ,     //By
                    
                    0 ,     //Cx
                    2       //Cy
                )
                
    alert ( angle );

I try to determine the angle between AB and BC

Source Link
Black
  • 20k
  • 45
  • 183
  • 292

Determine angle between 3 coordinates

Pictures say more then thousand words. As you can see in my screenshot i try to calculate the angle between the coordinates AB and BC, in this case the angle is obviously 90°. But how can i determine this angle with javascript code?

I found this thread and tried the accepted solution, but i always get 1.57instead of 90 like i expected. I rewrote the original function because i did not understood how to pass my parameters to it.

Please excuse my bad paint and math skills.

    function find_angle(Ax,Ay,Bx,By,Cx,Cy)
    {
        var AB = Math.sqrt(Math.pow(Bx-Ax,2)    +   Math.pow(By-Ay,2));    
        var BC = Math.sqrt(Math.pow(Bx-Cx,2)    +   Math.pow(By-Cy,2)); 
        var AC = Math.sqrt(Math.pow(Cx-Ax,2)    +   Math.pow(Cy-Ay,2));
        
        return Math.acos((BC*BC+AB*AB-AC*AC)    /   (2*BC*AB));
    }
    var angle = find_angle
                (
                    4 ,     //Ax
                    3 ,     //Ay
                    
                    4 ,     //Bx
                    2 ,     //By
                    
                    0 ,     //Cx
                    2       //Cy
                )
                
    alert ( angle );

I try to determine the angle between AB and BC