Rotation of line in c Or c++

sumit_goel

sumit_goel

@sumit-goel-GHakPk Oct 25, 2024
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

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • gaurav.bhorkar

    gaurav.bhorkar

    @gauravbhorkar-Pf9kZD Aug 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.
  • optimystix

    optimystix

    @optimystix-4yMPKC Aug 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.
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Aug 17, 2010

    Try bresenham algorithm
    change the coordinates of line accordingly
  • sumit_goel

    sumit_goel

    @sumit-goel-GHakPk Aug 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++.
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Aug 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();
    }