## jowana

Hello,

I have got an square image with a point specified by the user(not neccessary to be in the centre).
I want my program to draw a line or vector from that point to the boundary of the image.
Then, I want to draw the same vector again and again in a circular motion until reaching the first vector again.
So, to make it more clear, I want these vectors to be drawn equally spaced from each other.
So, I thought about applying rotation on the first vector. say, for example, for every 10 degrees draw a vector.

So at the end i want to have a center point with vectors around it drawn in equally space.

How can I apply this in C++ ?
is there a better way to do this this other than rotation and angles?

I will really appreciate your help.
hope you can help me as soon as possible.

Thanks.
Jowana .

## StuXYZ 731

The question is really do you know how to draw stuff in a c++ program and want help with the maths for making a 36 pointed star shape [10 degrees]. Or do you want help writing a C++ program to draw stuff.

If it is the maths, then the obvious way to do it is to note thThe question is really do you know how to draw stuff in a c++ program and want help with the maths for making a 36 pointed star shape [10 degrees]. Or do you want help writing a C++ program to draw stuff.

If it is the maths, then the obvious way to do it is to note that the unit vector constructed with the coordinates $$\cos(\theta), \sin(\theta)$$ and iterate through the angle from 0 to 360 degree (0 to 2*PI radians: C++ cos /sin functions are in radians!) and draw the appropriate line to the edge of the square.

So show us your basic code, and we will help a bit.

## jowana

my main problem is that i dont know how to program this. I have a good background in graphis But, i dont have much experience in coding it.
your explanation made it clearer for me now. But, how can i draw the lines?
i should draw a line first and then draw a line after each iteration.

Can you give me like hints or examples please?, I want to try coding it by myself but dont know how to start.

Thanks for your help.

## jowana

i can draw the line using the equation of the line. But, this will need to have two points. the first will always be (0,0) and the second will be a point on the edge of the square. teh question is: how can i find this point on the edge?

## Stefano Mtangoo 455

i can draw the line using the equation of the line. But, this will need to have two points. the first will always be (0,0) and the second will be a point on the edge of the square. teh question is: how can i find this point on the edge?

you just draw them as you would do in geometry. If you know geometry then either learn a GUI toolkit and use it or go for OpenGL. You must know C++ before invading OGL
Here are some links:
http://www.cprogramming.com/tutorial/opengl_introduction.html
http://www.euclideanspace.com/software/games/twod/openglcpp/index.htm