Graphics Minipulation
Author Message
Graphics Minipulation

Ok I have it where the end user can define a "SELECTION BOX" in the
picture frame.  Then I find the center of the box.  But I want to put
a elipse in the box.  I just don't know the math required to generate
it.  If anyone can help with where I could get mathmatical functions
to create curved lines it would be great.

EX:
0       50      100
5
10

The center of the square would be 5,50 so I want to draw a arc from
0,50 to 5,100..  Then I'll just draw arcs with the same formulia (if
possible) to complete the elipse.

----
Matthew Hazlett

Sun, 19 Jul 1998 03:00:00 GMT
Graphics Minipulation

Quote:

>I want to put an ellipse in the box.  I just don't know the math required
>to generate it.  If anyone can help with where I could get mathematical
>functions to create curved lines it would be great.

Well, I could give you the mathematical formulas, but in VB you don't
really need them to draw ellipses.

Just look in the Programmer's Guide, chapter 15. You use the command
"circle" to draw arcs. To get an ellipse instead of a circle, just
fill in the optional parameter "aspect". This is the ratio of y
compared to x. "Radius" is the larger of the two. By giving in a start
and an end angle, you can even draw only a part of the ellipse! The
one limitation is that your ellipse must stretch either horizontally,
or vertically. But that isn't really a problem, is it?

Anyway, you asked for it, so here are's the math:

Coordinates for one point:
x=mx+l*cos(angle)
y=my+h*sin(angle)

with angle in radians (=PI radians for 180). 0 gives a point at 3
o'clock, PI/2 gives you 12 o'clock.

Here is:
(mx,my) =  your middle point,
l = horizontal distance ellipse to middlepoint
h = vertical distance ellipse to middlepoint

All you have to do is to plot different points for several angles.
Better still, draw some straight lines between some calculated points.
Just make sure these points are close enough together.

The same limitation applies: if you do want the ellipse to stretch
some other direction than either horizontally or vertically, you'd
have to use rotation formulas (some combination of sines and cosines).
But I won't bother you with those now.

Hope I got you started,
Bart

Tue, 28 Jul 1998 03:00:00 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages

Powered by phpBB® Forum Software