From
Alexandr Filippov
→
To
All
18 April 2003
Hello everyone!
A subject is needed, and if it’s not difficult, an example in bass/acma.
Alexander
From
Anton Kolotvin
→
To
Alexandr Filippov
20 April 2003
Hello _Alexandr_! *Anton* writes to you!
18 Apr 03 20:42, _Alexandr Filippov_ ══. /All/:
AF> The subject is useful, and if it’s not difficult, an example in bass/acma.
AF>
The subject is simple to the point of disgrace :)
10 let a=10: let b=20: let x=100: let y=100
20 let s=3/(a+b)
30 for t=0 to 2*pi step s
40 plot x+a*sin(t), y+b*cos(t)
50 next t
that's right, offhand. The principle is simple:
10 - initialization. a= radius along the X axis, b = radius along the Y axis
20 - step calculation. The C can be changed to a smaller number - it will be
better quality, but slower.
30 - in a cycle we run t around the entire circle, from 0 to 360 degrees.
40 - put dots. It could have been in segments, but I didn’t feel like it :)
and if a and b are changed in the body of the cycle, you can get a spiral or something worse
:)
That's it! Very simple, IMHO. If you have any questions, ask.
Well, what else can I say?... Bye, _*Alexandr*_!
From
Oleg Grigoriev
→
To
Anton Kolotvin
23 April 2003
Let your enemies, Anton, die without sons!
20 Apr 2003 at 20:59, Anton Kolotvin => Alexandr Filippov:
AK> better quality, but slower. 30 - in a loop we run t throughout
AK> circles, from 0 to 360 degrees.
Up to 90 degrees is enough, and the rest is mirrored.
WBR, Oleg.
From
Kirill Frolov
→
To
Anton Kolotvin
24 April 2003
On Sun, 20 Apr 2003 19:59:40 +0400, Anton Kolotvin wrote:
AK> 20 - step calculation. A C can be exchanged for a smaller number - it will be
AK> better quality, but slower.
You can connect points with straight lines so that there are no breaks.
In general, there is some more normal algorithm (Bresenheim?) for constructing
ellipses and circles, but I don’t remember anymore.
--
[ZX]
From
Anton Kolotvin
→
To
Oleg Grigoriev
24 April 2003
Hello _Oleg_! *Anton* writes to you!
23 Apr 03 18:46, _Oleg Grigoriev_ ══. /Anton Kolotvin/:
AK>> better quality, but slower. 30 - in a loop we run t throughout
AK>> circles, from 0 to 360 degrees.
OG>
OG> up to 90 degrees is enough, and the rest should be mirrored.
Hmm, it really is possible, but I said that this is so, offhand, without optimization.
Well, what else can I say?... Bye, _*Oleg*_!
From
Dmitriy Nesmachny
→
To
Anton Kolotvin
27 April 2003
Hello Anton!
Sunday 20 Apr 2003 20:59:40, Anton Kolotvin -> Alexandr Filippov:
AK> 10 let a=10: let b=20: let x=100: let y=100
AK> 20 let s=3/(a+b)
AK> 30 for t=0 to 2*pi step s
AK> 40 plot x+a*sin(t), y+b*cos(t)
AK> 50 next t
It doesn't roll. Your ellipse axes are parallel to the coordinate axes. Ellipse equation,
taking into account the arbitrary rotation of its axes is unknown to me. So apparently
each point will need to be multiplied by the rotation matrix... :-(((
Best regards, Dmitriy.
From
Anton Kolotvin
→
To
Kirill Frolov
27 April 2003
Hello _Kirill_! *Anton* writes to you!
24 Apr 03 07:39, _Kirill Frolov_ ══. /Anton Kolotvin/:
KF> You can connect points with straight lines so that there are no breaks.
I talked about this. I just wrote the simplest thing that came into my head.
KF> In general, there is some more normal algorithm (Bresenheim?)
KF> construction of ellipses and circles, but I don’t remember anymore.
Let me remind you. It’s true in C, but I can also throw it in Vasik.
Algorithm for drawing an ellipse.
// drawing an almost exact ellipse using a fast integer algorithm;
void DrawEllipse(int x, int y, long int a, long int b,
unsigned long int color)
// drawing 1/8 of the function graph D = t0+t1+t2 = (a^2)*(y^2) +
// + 2*(a^2)*y + (x^2)*(b^2) - x*(b^2) - (a^2)*(b^2) + (a^2) + (b^2)/4,
// x>=0, y>=0 or y=-1+(b/a)*sqrt(-(x^2)+x+(a^2)-1/4), x>=0, y>=0
// then adjusting and drawing another 1/8 of the slightly modified
// a similar graph - an almost exact ellipse is obtained}
{int ex, ey; long int aa, aa2, bb, bb2, d, dx, dy;
// Setting initial values; t0:=aa-bb*a+(bb div 4); t1:=0; t2:=bb2*a;
ex = a; ey = 0; aa = a * a; aa2 = aa * 2; bb = b * b; bb2 = bb * 2;
d = aa - bb * a + (bb % 4); dx = aa; dy = bb2 * a;
DrawPixel(x - ex, y, color); DrawPixel(x, y - b, color);
DrawPixel(x + ex, y, color); DrawPixel(x, y + b, color);// Drawing 1/8 of the graph, and symmetrical output in 1,2,3,4 quarters;
while (dx < dy)
{if (d > 0)
{ex--;
dy = dy - bb2; // DY = -bb2 * (a - ex);
d = d - dy; // t1:=t1-dy = bb*(1+a-ex)*(a-ex)-(a-ex)*bb2*a;
}
ey++;
dx = dx + aa2; // DX = aa2*ey;
d = d + dx; // t2:=t2+aa+dx = aa*EY*(1+EY)+EY*aa; D = t0+t1+t2;
DrawPixel(x + ex, y + ey, color); DrawPixel(x + ex, y - ey, color);
DrawPixel(x - ex, y + ey, color); DrawPixel(x - ex, y - ey, color);
}
// Adjustment: decrease D to match radius = b along Y coordinate;
d = d + ( (3*(bb-aa) % 2) - (dx-aa+dy) ) % 2; dy = dy - bb;
// Drawing the remaining 1/8 of the graph, and symmetrical output at 1,2,3,4
// quarters;
while (ex > 0)
{if (d < 0) {ey++; dx = dx + aa2; d = d + dx;}
ex--; dy = dy - bb2; d = d - dy;
DrawPixel(x + ex, y + ey, color); DrawPixel(x + ex, y - ey, color);
DrawPixel(x - ex, y + ey, color); DrawPixel(x - ex, y - ey, color);
}
}
I hope there is no need for comments. in principle, everything should be clear.
Well, what else can I say?... Bye, _*Kirill*_!