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  
 
 [ 3 post ] 

 Relevant Pages 

1. graphics filter to convert array(x,y) to standard graphics

2. Saving graphics objects to an standard graphics file

3. Graphic example - 'smart' connected graphic objects

4. Graphic example - 'smart' connected graphic objects

5. Overlaying text onto a graphic and saving as graphic

6. How to overlay graphics on text/graphics

7. Need graphics expert! How to draw a large graphics image in memory?

8. - Help Please, I am sending an HTML Form with graphics from a VB5 .exe graphics don't show? (0/1)

9. UI graphics issues: how to get smooth graphics for form and control transitions?

10. UI graphics issues: how to get smooth graphics for form and control transitions?

11. Graphics in reports

12. Graphic source in code??

 

 
Powered by phpBB® Forum Software