CrazyEngineers
  • Rotation of line in c Or c++

    sumit_goel

    Member

    Updated: Oct 25, 2024
    Views: 1.4K
    hello friends,
    I have another problem that is how to rotate the line at 90 degree from the origin.
    for example, i have a line x,y


    __________________
    x.......................... y
    and now i want to rotate this line at 90 degree as shown bellow

    90
    |
    |
    |
    |
    |
    |
    |
    |
    X

    rotation at 90 degree

    Pls help me in solving this problem
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • gaurav.bhorkar

    MemberAug 17, 2010

    Can you post the code you've tried so far?

    Here's my suggestion,
    Fix one end of the line and then change the coordinates of the other end appropriately.
    Are you sure? This action cannot be undone.
    Cancel
  • optimystix

    MemberAug 17, 2010

    what is the problem ? just substitute the corresponding values for 90 degree in the rotational transformation matrix and solve it.
    where are u facing the problem ? share with us so that we can help.
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberAug 17, 2010

    Try bresenham algorithm
    change the coordinates of line accordingly
    Are you sure? This action cannot be undone.
    Cancel
  • sumit_goel

    MemberAug 18, 2010

    Hello friends
    first of all i would like to thanks to all for giving response to my problem. Actually i made a table fan in c++ and i want to rotate the fan. but for this first of all i should know how to rotate the line. then i can proceed to make rotation of fan.In the above problem i simply want to ask how to rotate the line at 90 degree.I am beginner of graphics programs in c++. and also Can anyone tell me from which site i can learn simple graphics programs in c++.
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberAug 18, 2010

    Try this program but i have not execute this .
    It will draw a line
    Now for rotating it change its co-ordinates accordingly
    #include  <graphics.h>
    #include  <math.h>
    #include <conio.h>
    
    void main(void)
    {
        int   driver = DETECT,mode;
        
        int   x=180,y=180;
    
        initgraph(&driver,&mode,"c:\\tc\\bgi");
        
        for(;;)
    {
        
          line(360,360,x,y);
            
            
    }
        getch();          
        closegraph();
    }
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register