Qbasicnews.com

Full Version: curves and ovals
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How can I make curves and ovals? I know how to make circles, but I don't understand how I can make ovals and curves.
CIRCLE can be used to draw curves. Look it up in QBHELP.
Thats not a way of answering a question.

Heres an example:

Code:
CONST PI=3.141593
SCREEN 2
'Draw a circle with the upper-left quarter missing.
'Use negative numbers so radii are drawn.
CIRCLE (320,100), 200,, -PI, -PI/2
'Use relative coordinates to draw a circle within the missing quarter.
CIRCLE STEP (-100,-42),100
'Draw a small ellipse inside the circle.
CIRCLE STEP(0,0), 100,,,, 5/25
'Display the drawing until a key is pressed.
LOCATE 25,1 : PRINT "Press any key to end.";
DO
LOOP WHILE INKEY$=""

Thats borrowed from qb v7.1's help =P

Have a look at the aspect ratio part
for curves, courtesy of myself and dav's lovely code post:
http://home.carolina.rr.com/davs/codepos...BEZIER.BAS

Bezier curves are curves based on 4 points, which draw a line between two of the points, and pulling towards the other two points. It's a pretty handy tool for systematic calculation of the curves. Shame you either have to use floating or fixed point decimal values to use it, though.
lines and point-by-point drawing are definetly "better" than the CIRCLE command of QB.

Anonymous

Quote:lines and point-by-point drawing are definetly "better" than the CIRCLE command of QB.

I totally agree. And GOTO is definitely "better" than SUB, right nyahaha Big Grin
no.
A faster way to calculate curves is to derivate it n times until it no longer has any variables with exponent. This means derivating twice with quadrics, three times with cubics etc. Then in the loop calculate the change as a series of additions.


dy = y(x + k) - y(x)
ddy = dy(x + k) - dy(x)

then
for i = 0 to steps-1
y = y + dy
dy = dy + ddy
next i

Simple really, but fast.
Yeah, that's a good way to go about it Blitz. Except chances are no one is going to understand you until they've taken several Calculus courses and been programming for a few years. Smile
Aga, its not that difficult. Anyone with a basic understanding of calculus and i mean *understanding* not just the formulae can easily program it =).

The advanced stuff doesnt kick in until you are integrating 2D surfaces with double integrals and 3D with triple integrals =P. Thats 'hard' to understand. But its simple *if* and only *if* you have the knowledge of what an integral/derivative of a function *is*
Pages: 1 2