Click to See Complete Forum and Search --> : draw curved lines.


kedaman
Feb 9th, 2001, 09:12 PM
You want to draw a sine curve that is angled?

treklipper
Feb 10th, 2001, 11:02 AM
Yep!

I would like to draw a curved line that is angled.
It should work for angles from 1 to 360

kedaman
Feb 10th, 2001, 11:44 AM
Const deg2rad = 1.74527777777778E-02
offsetx = ScaleWidth \ 2
offsety = ScaleHeight \ 2
amplitude = ScaleWidth \ 8
frequency = 0.01
phi = 120 * deg2rad 'to convert degree to radians, multiply with pi/180
length = 1000
centerx = ScaleWidth \ 2
centery = ScaleHeight \ 2

For pixelx = 0 To length
Y = offsety + Sin(pixelx * frequency) * amplitude
X = offsetx + pixelx

dx = -centerx + X
dy = -centery + Y
r = Sqr(dx * dx + dy * dy)
theta = Sgn(dy) * ArkTangent(dy, dx) + phi
PSet (centerx + Cos(theta) * r, centery + Sin(theta) * r)

Next pixelx
End Sub

I did this one using guv's safe arctan that you can get here:
http://forums.vb-world.net/showthread.php?s=&threadid=53924

treklipper
Feb 10th, 2001, 04:21 PM
Hi!

There was some of your code I did not understand.

This line of code:
theta = Sgn(dy) * ArkTangent(dy, dx) + phi

What sort of a function is ArkTangent?
It is not anywhere in the code you posted

parksie
Feb 10th, 2001, 04:45 PM
You get ArkTangent from the link he quoted :rolleyes:

kedaman
Feb 10th, 2001, 04:45 PM
go for the link and copy guv's code for it ;)

Sastraxi
Feb 14th, 2001, 09:38 PM
Or you could use sin and cos to do it....

but only if the curve was square (eg X1=50,X2=0,Y1=50,Y2=0) then the centerpoint (origin) would be 0,50 and so on...)