We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Callenge 6 - Draw conics
#3
Here is my cycloid  Blush
Code:
GraphicsWindow.BackgroundColor = "White"
GraphicsWindow.PenColor = "Blue"
GraphicsWindow.PenWidth = 2

' Let's set the parameters
radius1 = 9 ' Radius of a rolling circle
radius2 = 90 ' Radius of a fixed circle
lineLength = radius1 + 15 ' Length of line from the center of rolling circle
centerX = 200 ' Center of the fixed circle along X
centerY = 200 ' Center of the fixed circle along Y

' Initial coordinates of the point at the end of the line
x = centerX + radius2 + lineLength
y = centerY

' Angle of rotation
angle = 0

While (angle < 360 * 5) ' Draw several turns
  ' ВCalculate the coordinates of the center of the rolling circle
  rollingCenterX = centerX + (radius2 + radius1) * Math.Cos(angle * Math.Pi / 180)
  rollingCenterY = centerY + (radius2 + radius1) * Math.Sin(angle * Math.Pi / 180)
 
  ' Calculate the coordinates of the point at the end of the line
  x = rollingCenterX - lineLength * Math.Cos((radius2 + radius1) / radius1 * angle * Math.Pi / 180)
  y = rollingCenterY - lineLength * Math.Sin((radius2 + radius1) / radius1 * angle * Math.Pi / 180)
 
  ' Draw a dot
  GraphicsWindow.DrawEllipse(x, y, 2, 2)
 
  ' Increasing the angle
  angle = angle + 1
EndWhile
[-] The following 1 user Likes AbsoluteBeginner's post:
  • litdev
Reply


Messages In This Thread
Callenge 6 - Draw conics - by litdev - 09-14-2024, 09:22 AM
RE: Callenge 6 - Draw conics - by AbsoluteBeginner - 09-15-2024, 12:57 PM
RE: Callenge 6 - Draw conics - by litdev - 09-17-2024, 08:12 AM
RE: Callenge 6 - Draw conics - by litdev - 09-25-2024, 09:12 AM
RE: Callenge 6 - Draw conics - by jrmrhrb00 - 09-26-2024, 08:11 PM
RE: Callenge 6 - Draw conics - by litdev - 09-26-2024, 08:59 PM
RE: Callenge 6 - Draw conics - by z-s - 09-27-2024, 05:23 AM
RE: Callenge 6 - Draw conics - by jrmrhrb00 - 09-27-2024, 11:55 AM
RE: Callenge 6 - Draw conics - by litdev - 09-27-2024, 01:28 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)