Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

The signed angle between two Vector3D points

Engaged ,
Apr 17, 2012 Apr 17, 2012

Hi,

Can someone show me how to get the signed angle between two Vector3D points?

Thanks!

TOPICS
ActionScript
4.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 18, 2012 Apr 18, 2012

the Vector3D class has a function called angleBtween() does that not do what you want? not it returns an angle in radians

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 18, 2012 Apr 18, 2012

Hi _spodboyle,

That returns an unsigned angle.  A signed angle returns a minus or positive angle depending on which side one vector is compared to the other.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2012 Apr 18, 2012
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 18, 2012 Apr 18, 2012

Hi Sinious,

that looks promising.  I wish that the formula was written out, I'm not sure I understand what the responder in that post is saying : (

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 18, 2012 Apr 18, 2012
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 18, 2012 Apr 18, 2012

Hi _spoboyle,

That looks helpful.  How do I get Vn?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 18, 2012 Apr 18, 2012

well this is the bit I don't really understand

Vn is the normal to the plane containing Va and Vb. You could find Vn by calculating the normalised corssproduct of Va and Vb

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 18, 2012 Apr 18, 2012

I've just tried what i said above and it's didn't give me what i expected

here is another discussion

http://www.physicsforums.com/showthread.php?t=262649

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 18, 2012 Apr 18, 2012

I don't fully understand it or even how you would use it but here is an example I wrote in AS3

package

{

          import flash.display.Sprite;

          import flash.events.Event;

          import flash.geom.Vector3D;

 

          public class Main extends Sprite

          {

                    public function Main():void

                    {

                              if (stage)

                              {

                                        init();

                              }

                              else

                              {

                                        addEventListener(Event.ADDED_TO_STAGE, init);

                              }

                    }

 

                    public function init(e:Event = null):void

                    {

                              removeEventListener(Event.ADDED_TO_STAGE, init);

 

                              var a:Vector3D = new Vector3D(2, 1, 3);

                              a.normalize();

                              var b:Vector3D = new Vector3D(1, 2, 3);

                              b.normalize();

 

                              var sina:Number = a.crossProduct(b).length / (a.length * b.length);

                              var cosa:Number = a.dotProduct(b) / (a.length * b.length);

 

                              var sinb:Number = b.crossProduct(a).length / (a.length * b.length);

                              var cosb:Number = b.dotProduct(a) / (a.length * b.length);

 

                              var radiansa:Number = Math.atan2(sina, cosa);

                              var radiansb:Number = Math.atan2(sinb, cosb);

 

                              var n:Vector3D = a.crossProduct(b);

                              n.normalize();

 

                              var signa:Number = n.dotProduct(a.crossProduct(b));

                              var signb:Number = n.dotProduct(b.crossProduct(a));

 

                              if (signa < 0)

                              {

                                        radiansa = -radiansa;

                              }

 

                              if (signb < 0)

                              {

                                        radiansb = -radiansb;

                              }

 

                              var degreesa:Number = radiansa * 180 / Math.PI;

                              trace("angle A to B: " + degreesa);

 

                              var degreesb:Number = radiansb * 180 / Math.PI;

                              trace("angle B to A: " + degreesb);

 

                    }

          }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 18, 2012 Apr 18, 2012
LATEST

that looks promising.

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines