draw a line inside a circle
-
I am using graphics to create a speed meter. To do this I would like to draw a line from the center of the circle to the side of the circle. You would normaly use sinus etc. for this, but my circle isn't really round, it's more oval like (the height is bigger than the width). How is it possible to draw this line?
-
I am using graphics to create a speed meter. To do this I would like to draw a line from the center of the circle to the side of the circle. You would normaly use sinus etc. for this, but my circle isn't really round, it's more oval like (the height is bigger than the width). How is it possible to draw this line?
Hi, a circle with radius r at the origin is represented by
x*x + y*y = r*r
an ellips with big radius r at the origin is represented byx*x + a*a*y*y = r*r
where a (a factor larger than 1) is the ratio between the large radius (along the x-axis) and the small radius (along the y-axis). So basically an ellips is a circle where you reduce y to y/a, and for each point (x,y) that would sit on the circle, the point (x, y/a) would sit at the corresponding location on the ellips. To visualize: paint a circle on a sheet of paper, now tilt the sheet around a horizontal line: the circle becomes an ellips and all vertical dimensions shrink by the same factor. Depending on what you want exactly, this might be all you need. When angles are involved, it gets a little bit more complex. :)Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
-
Hi, a circle with radius r at the origin is represented by
x*x + y*y = r*r
an ellips with big radius r at the origin is represented byx*x + a*a*y*y = r*r
where a (a factor larger than 1) is the ratio between the large radius (along the x-axis) and the small radius (along the y-axis). So basically an ellips is a circle where you reduce y to y/a, and for each point (x,y) that would sit on the circle, the point (x, y/a) would sit at the corresponding location on the ellips. To visualize: paint a circle on a sheet of paper, now tilt the sheet around a horizontal line: the circle becomes an ellips and all vertical dimensions shrink by the same factor. Depending on what you want exactly, this might be all you need. When angles are involved, it gets a little bit more complex. :)Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
Thank you for explaining this. Seems not to hard. But my question is indeed about angles. If you would like to take a gast look to this picture so you understand what I'm making: http://technology.amis.nl/blog/wp-content/images/postReadSpeedSpeedo.jpg[^] The thing I want to make is an arrow like that based on an angle. The shape of the arrow is not a big deal, it's about the angle and how to know the length of the arrow.
-
Thank you for explaining this. Seems not to hard. But my question is indeed about angles. If you would like to take a gast look to this picture so you understand what I'm making: http://technology.amis.nl/blog/wp-content/images/postReadSpeedSpeedo.jpg[^] The thing I want to make is an arrow like that based on an angle. The shape of the arrow is not a big deal, it's about the angle and how to know the length of the arrow.
Well, that image shows a circle, if all you want to do is compress or stretch it in one dimension, then just do that by multiplying one coordinate by a constant factor. Give it a try in an app such as Photoshop by changing one component of the image size (uncheck "keep aspect ratio" or whatever they called it). The one situation where you would need angle stuff is where you would want an arrow moving at a constant angular speed in the ellips (which would not then be a constant angular speed in the corresponding circle). :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
-
Well, that image shows a circle, if all you want to do is compress or stretch it in one dimension, then just do that by multiplying one coordinate by a constant factor. Give it a try in an app such as Photoshop by changing one component of the image size (uncheck "keep aspect ratio" or whatever they called it). The one situation where you would need angle stuff is where you would want an arrow moving at a constant angular speed in the ellips (which would not then be a constant angular speed in the corresponding circle). :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
Yes, you're totaly true that I can use a photoshop-like program. But I really want to calculate it on my own. The picture is created by code, everything has to be configurable, for instance: the hight, the width, the amount of arrows and where the arrows point to. The problem is that the width is not always equal to the height. So that's the only problem I have. I know it is possible because it's allready solved by microsoft (Graphics.drawPie). I hope that you can tell me how to calculate this eclipse like with the only variables you have: the angle, the width, the height.
-
Yes, you're totaly true that I can use a photoshop-like program. But I really want to calculate it on my own. The picture is created by code, everything has to be configurable, for instance: the hight, the width, the amount of arrows and where the arrows point to. The problem is that the width is not always equal to the height. So that's the only problem I have. I know it is possible because it's allready solved by microsoft (Graphics.drawPie). I hope that you can tell me how to calculate this eclipse like with the only variables you have: the angle, the width, the height.
Still having a hang-over from mardi gras? I explained how ellipses work. I gave you the math. I suggested you look at your picture, when Photoshop stretches it, so you don't have to create or modify any code to see and maybe understand how a scale transform turns a circle into an ellipse. By now you should realize all it takes is adding a scale factor to your Graphics code, either explicitly or by providing a ScaleTransform or Matrix. For me this topic is closed.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
-
Still having a hang-over from mardi gras? I explained how ellipses work. I gave you the math. I suggested you look at your picture, when Photoshop stretches it, so you don't have to create or modify any code to see and maybe understand how a scale transform turns a circle into an ellipse. By now you should realize all it takes is adding a scale factor to your Graphics code, either explicitly or by providing a ScaleTransform or Matrix. For me this topic is closed.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
-
I am using graphics to create a speed meter. To do this I would like to draw a line from the center of the circle to the side of the circle. You would normaly use sinus etc. for this, but my circle isn't really round, it's more oval like (the height is bigger than the width). How is it possible to draw this line?
thanx!!!!!!!!!!111
-
I am using graphics to create a speed meter. To do this I would like to draw a line from the center of the circle to the side of the circle. You would normaly use sinus etc. for this, but my circle isn't really round, it's more oval like (the height is bigger than the width). How is it possible to draw this line?
-
IF: Xo, Yo - the center of the ellipse Rx, Ry - the two radius' alpha - is the angle in radians!!! Calculate: X = Xo + Rx*cos(alpha); Y = Yo + Ry*sin(alpha); Draw: a line from (Xo,Yo) to (X,Y) *In case you have a circle, then Rx=Ry = R of circle