Menu

How to calculate an (Roll, Turn, Pitch) angle from two object?

Help
Roman
2017-02-12
2017-02-12
  • Roman

    Roman - 2017-02-12

    Stupid question.
    I can not calculate the angle.

    I have 4 xyz points (A, B, C, D).
    I create 3 object:
    Obj1 = Point AB.
    Obj2 = Point CD.

    Obj3 = Сrossing Obj1, Obj2.
    I need set Roll, Turn, Pitch angle to Obj3.

    If Obj / Onj2 rotated one axis then works.
    If Obj / Onj2 rotated two or three axes then not works.


    http://i.imgur.com/ZyWnDyD.jpg

    Help me please..

    My very bad / stupid / wrong code:

            Obj3.RollAngle := Obj1.RollAngle;
            Obj3.PitchAngle := Obj2.PitchAngle;
    
            if Point1.x<Point2.x then
            Obj3.TurnAngle :=  Obj1.TurnAngle else
            Obj3.TurnAngle := -Obj1.TurnAngle;
    
            if Point1.y<Point2.y then Obj3.PitchAngle := -Obj3.PitchAngle;
            if Point3.x<Point4.x then Obj3.PitchAngle := -Obj3.PitchAngle;
            if Point3.y>Point4.y then Obj3.PitchAngle := -Obj3.PitchAngle;
    
     

    Last edit: Roman 2017-02-12
  • Jerome.D (BeanzMaster)

    Hi check in GLVectorGeometry unit you'll find what you search i think
    cf :
    function IsColinear(const V1, V2: TVector): Boolean;
    function VectorAbs(const V: TVector): TVector;
    function VectorRotateAroundX,Y,Z(const V: TAffineVector; alpha: Single) : TAffineVector;
    function VectorPerpendicular(const V, n: TAffineVector): TAffineVector;
    function VectorReflect(const V, n: TAffineVector): TAffineVector;
    function AngleBetweenVectors(const a, b, ACenterPoint: TVector): Single;
    ect ....

    I think it exist a solution for calculating angle with the up and direction values but don't remember how to do and where i saw something similar.

     

    Last edit: Jerome.D (BeanzMaster) 2017-02-12
  • Roman

    Roman - 2017-02-13

    I still can not with Vector functions :[

    i set Obj3 parent := Obj1;
    Then search TurnAngle.

    This work:

    ta:=0;
    vd:=999999;
    tvd:=999999;
    tmpOBJ.Parent:=Obj3;
    tmpOBJ.Position.SetPoint(0,0,0.8);
    for i:=0 to 360 do
    begin
      Obj3.TurnAngle:=i;
      tvd:=VectorDistance(tmpOBJ.AbsoluteAffinePosition,Obj2.AbsoluteAffinePosition);
      if vd>tvd then
      begin
        vd:=tvd;
        ta:=i;
      end;
    end;
    Obj3.TurnAngle:=ta;
    

    BUT this crazy method :[

    How to do the right thing?

     

    Last edit: Roman 2017-02-13

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.