Results 1 to 7 of 7

Thread: draw curved lines.

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You want to draw a sine curve that is angled?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  2. #2
    New Member
    Join Date
    Feb 2001
    Posts
    3

    Curved line with angle.

    Yep!

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

  3. #3

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    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/showthrea...threadid=53924
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    New Member
    Join Date
    Feb 2001
    Posts
    3

    did not understand some of your code..

    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
    Chris

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You get ArkTangent from the link he quoted
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    go for the link and copy guv's code for it
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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...)
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width