Pure maths, physics, chemistry, etc.: brain-training tasks that have nothing to do with trade [Part 2] - page 20
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
In polar coordinates, everything will be fine there. But when you switch to normal coordinates, the same thing will come out.
What's the short answer? You have to dance from the stove. If evaluating the area of values, then the reduction to this form is not necessary.
_____________
By the way, it's not hard to get the coefficients of the equation.
And one more thing by the way -- the original ellipse before the rotation is not expressed by such a function either.
In polar coordinates, everything will be fine there. But when you switch to normal coordinates, the same thing will come out.
What's the short answer? You have to dance from the stove. If evaluating the area of values, then the reduction to this form is not necessary.
_____________
By the way, it's not hard to get the coefficients of the equation.
And one more thing by the way -- the original ellipse before the rotation is not expressed by such a function either.
The task is to draw a rotated ellipse pixel by pixel. Not an ellipse, but a flattened circle is fine too.
An ellipse and a flattened circle are the same thing.
So, there is an equation -- x^2/a^2 + y^2/b^2 = 1 -- that is an ellipse. (1)
Further -- there is a transformation. Expressing x y by x' y' is no problem. Substituting into (1) isn't a problem either.
Then we loop over x in increments of 1 and loop over y in increments of 1.
And then we measure these points, and it's kind of easy.
The only problem is the area of values. This is where you have to think about it.
An ellipse and a flattened circle are the same thing.
So, there is an equation -- x^2/a^2 + y^2/b^2 = 1 -- which is an ellipse. (1)
Further -- there is a transformation. Expressing x y by x' y' is no problem. Substituting into (1) isn't a problem either.
Then we loop over x in increments of 1 and loop over y in increments of 1.
And then we measure these points, it's not so hard.
The only problem -- the range of values. This is where you have to think about it.
If a flattened circle and an ellipse are the same, then y=k*sqr(r^2-x^2) is an ellipse.
If you get y from x and rotate it, you get pixel corners (for example pixel, bottom pixel and right pixel). Any sifting out pixels and connecting the resulting points with a line will look crooked. Tried a bunch of ways. The only nice way is the function y' from x', if the points are farther apart than one pixel, then connect them with a line.
In short, I would probably calculate the points in the polar system and then remove the extra ones according to the 8-linkage principle.
I'll give it a try.
If flattened circle and ellipse are the same, then y=k*sqr(r^2-x^2) is an ellipse.
If you get y from x and rotate, there will be corners of pixels (e.g. pixel, bottom pixel and right pixel). Any sifting out the pixels and connecting the resulting points with a line will look crooked. Tried a bunch of ways. The only nice way is as a function of y' from x', if the points are further apart than one pixel, then connect them with a line.
Do you need to draw it in one colour only, or can you antialiased it? If smoothing, you can look for a ready implementation of Bresenham algorithm for ellipse
P.S. Here's something else I came across http://www.geometrictools.com/Documentation/IntegerBasedEllipseDrawing.pdf
Do I need to do it in one colour only, or can I do it in an antialiased raster? If smoothing, you can look for a ready implementation of the Bresenham algorithm for the ellipse
P.S. Here's more from http://www.geometrictools.com/Documentation/IntegerBasedEllipseDrawing.pdf
In one colour, if with anti-aliasing, you'll need to do everything with anti-aliasing.
* * *
I guess the ellipse won't be until next season :)
Something came up, of course. I didn't really come up with it, I saw how Renat drew a circle. Check the whole area, whether the point is inside or outside the figure. Then come to the ready figure from four sides and colour the outline. There is another drawback with this case - if it is not a rotated ellipse, it is necessary to calculate and reflect for one quarter. If it is a rotated ellipse, you have to calculate for half of it and reflect it. I also want to make a notch to draw sectors and slices...
Integer:
If rotated, calculate for half and reflect. I also want to make a notch to draw sectors, slices...
Especially polar coordinates!
Partly but not quite. In a square area for each x and y, first we rotate, transform the rotated x and y to polar coordinates - we obtain the distance of the point from the centre (r) and angle (fi), by the angle fi, given radius and coefficient we calculate the distance of the ellipse extreme point from the centre, compare with r and find out if the point is inside or not.
In any case, you will need to divide it into quarters or halves and reflect.
If you draw in polar coordinates straight away, you have to clean up some points later, and if you draw solid, it's easier to contour it later. Maybe it's not like that, but there are obviously more complications than it seems.