Rotating a partial section of a circle around its center with constant velocity



  • Hi "all",

    welcome to community.

    First, there is a conceptional problem to solve.

    Hit in math a point of real numbers is not a tricky thing, because you can choose in rotatation also real numbers. But in programming you have to define values by types; generic or not doesn't matter. So you have to test or prove points will be matched in line by rotation with your chosen type first.

    Second, you have to understand the math behind it:
    http://en.wikipedia.org/wiki/Euler_angles
    http://en.wikipedia.org/wiki/Linear_algebra
    http://en.wikipedia.org/wiki/Vector_space
    http://en.wikipedia.org/wiki/Basis_(linear_algebra)
    http://en.wikipedia.org/wiki/Cross_product
    http://en.wikipedia.org/wiki/Transformation_matrix#Other_kinds_of_transformations
    (tailor it for 2-D rotation and funtional plant description)

    I don't know your background. So good luck! 🙂

    An addition for my German fellows:
    http://de.wikipedia.org/wiki/Homogene_Koordinaten



  • Thank you Prof84, the information provided by you was very useful. I've working on those and need further help.

    From the Math, the rotation matrix for the 2D case, i get two equations as follows:

    x1 = x cos(θ) + y sin(θ)

    y1 = y cos(θ) - x sin(θ)

    From this, for my problem, i know all coordinates of the nodes (x1,y1) and (x,y), and if i am able to find angle for each point, my problem is solved. And for that, i tried adding and abstracting them to get a relation for θ, but was not successful. Any hint or source will be a G8 help. thank you in advance.

    Regards
    PS


  • Mod

    If you want to know the polar angle of a point, you should have a look at atan2. With this and a bit of vector geometry you should be able to solve your problem.



  • @psr1978:
    You are welcome. Look especially at the external links reference in C++ programming of SeppJ's Wikipedia link.

    By the way, what are you doing if
    Degree * velocity/timeframe >= 2π ?
    Means more then a cycle per frame.



  • Respect SeppJ and Mr.Prof84,

    Your input helped me a lot. I tried atan2 function and it seems it is not working as i desired, but One more small clarification: Does the atan2 function will work as it should only when the center of the circle is at (0,0) or it will it doesn't matter?

    And for Prof84: Actually i need to do this for several rotations. It doesn't matter if θ > 2π. THank you once again.

    Regards,

    PS


  • Mod

    atan2 assumes that the center of your circle is at (0,0).



  • Die Grundidee von atan2() ist wohl die:
    Presumably the main idea of atan2() is this:

    For i = 1, TimeSteps
    
       Degree = TIME * velocity         ! Get New Angle (Rotating with constant velocity)
    
       StrtRad =  Degree * deg2rad      ! Convert into RADIANS (POINT A)
       EndRad  = (Degree+20)*Deg2Rad    ! Convert into RAD. (POINT B) 20° Away from A
    
       StrtX = originx + (cos(StrtRad)*Radius)    ! New Position in X-Coordinate of Point A
       StrtY = originy + (sin(StrtRad)*Radius)    ! New Position in Y-Coordinate of Point A
    
       EndX = originx + (cos(EndRad)*Radius)      ! New Position in X-Coord. of Point B
       EndY = originy + (sin(EndRad)*Radius)      ! New Position in X-Coord. of Point B
    
       For j = 1, NumPoints ! Loop over all Points over the Circumfrence
          ! let PointsX = X-Coord. of the Point
          ! let PointsY = Y-Coord. of the Point
          Angel = atan2(PointsY-originy,PointsX-originy)  ! Angel of the Point
          if ( (StartRad .lt. Angel) .and (Angel .lt. EndRad)) then
             ! Point is between A and B
          end if
       End For                                    ! Loop on Nodes
    End For                                       ! Loop on Time steps
    

    Aber das klappt von und hinten nicht.
    But this dosn't work at all.

    Vielleicht geht das:
    Perhaps this works:

    For i = 1, TimeSteps
    
       Degree = TIME * velocity         ! Get New Angle (Rotating with constant velocity)
    
       StrtRad =  Degree * deg2rad      ! Convert into RADIANS (POINT A)
       EndRad  = (Degree+20)*Deg2Rad    ! Convert into RAD. (POINT B) 20° Away from A
    
       NormalizedStartRad = fmod(StrtRad+PI,2*PI)-PI ! Now beween -PI and PI
       For j = 1, NumPoints ! Loop over all Points over the Circumfrence
          ! let PointsX = X-Coord. of the Point
          ! let PointsY = Y-Coord. of the Point
          Angel = atan2(PointsY-originy,PointsX-originy)  ! Angel of the Point betreen -PI and PI
          if (Angel .lt. NormalizedStartRad)
             Angel=Angel + 2*PI
          ! Now Angel>=NormalizedStartRad AND Angel<NormalizedStartRad+2*PI
          if ( (Angel - NormalizedStartRad) .lt. 20 ) then
             ! Point is between A and B
             ! For funny animantions like http://www.youtube.com/watch?v=6sqCJ0cQ-q8
             ! draw the point with brightness (Angel - NormalizedStartRad) / 20 * maxBrightness
          end if
       End For                                    ! Loop on Nodes
    End For                                       ! Loop on Time steps
    


  • volkard schrieb:

    ! For funny animantions like http://www.youtube.com/watch?v=6sqCJ0cQ-q8
             ! draw the point with brightness (Angel - NormalizedStartRad) / 20 * maxBrightness
    ...
    

    You presumed it's just a game and in two years during CT some medical staff will call the funny skull layer animation the 'volkard effect'! 😃

    volkard schrieb:

    NormalizedStartRad = fmod(StrtRad+PI,2*PI)-PI ! Now beween -PI and PI
       For j = 1, NumPoints ! Loop over all Points over the Circumfrence
          ! let PointsX = X-Coord. of the Point
          ! let PointsY = Y-Coord. of the Point
          Angel = atan2(PointsY-originy,PointsX-originy)  ! Angel of the Point betreen -PI and PI
    

    You have an invaild line of points in atan2 for +&pi[/e ]and -[e]pi;, because of discontinuous of atan2 both are the same in circle. It doesn't matter if you shift the offset to +/-Π. So he has to prove if there are any/no points on the line as well.

    @psr1978:
    I hope we don't support you now for target marking of Eurofighter or adjusting space telescopes or anything else. 🕶 Otherwise we need some more requirements.

    (The german contributions are some minor troll posts. Don' t bother. Add: already canceled)



  • Ach, halt Dich aus Fachdiskussionen raus.



  • volkard schrieb:

    Ach, halt Dich aus Fachdiskussionen raus.

    Means he disagrees. I assume because math says it's a semi-open intervall of atan by definition. He is right, my fault, wrong fairy tale.

    But we have types and not real numbers - always risky.
    I have a second trap in mind:

    One of my footshots in history: You have an discontinueous function, transfer some vectors to another map and use some differential functions and searching weeks for the bug.

    http://en.wikipedia.org/wiki/Differentiable_manifold

    Add:
    <ot>
    Concerning this problem I found recently a nice solution for prevention:
    http://en.wikipedia.org/wiki/Penrose_graphical_notation
    http://de.wikipedia.org/wiki/Penrosesche_graphische_Notation
    http://en.wikipedia.org/wiki/Coxeter-Dynkin_diagram
    </ot>



  • So Guys, Thank you all for your Contribution. VOLKARD thank you for your help.

    As i am not a Math Profi, i am confused (With VOLKARD's implementation). I have implemented as follows:

    ActNodeRad = atan2(COORDS(2),COORDS(1))
    
          If ((ActNodeRad .gt. EndPtRad) .or. ! P O I N T  1
         >    (ActNodeRad .lt. StrtPtRad)) then
    
             write(*,*) 'N O T  Found Region'         
          else
             write(*,*) 'Found Region'
          end if
    

    So, this seems a step further. But still it seems not working as required. As VOLKARD mentioned, do i have to Normalise or not? Prof84 says no need to Normalise it. But any Hint why the code mentioned above, is still not working? Any help please! Thank you all..


Anmelden zum Antworten