LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Epicycloids

Root / Submissions / [.]

MZ952Created:
EPICYCLOID OriginX, OriginY, CentralRadius, TangentialRadius, ScaleFactor, Color
DEF EPICYCLOID X%,Y%,R0#,R1#,SF#,COL%
 DIM I#, RR# = R0#+R1#, S# = 1/3/R0#/SF#
 FOR I# = 0 TO PI()*2 STEP S#
  DIM X0# = RR#*COS(I#) - R1#*COS((RR#*I#)/R1#)
  DIM Y0# = RR#*SIN(I#) - R1#*SIN((RR#*I#)/R1#)
  GPSET X0#*SF#+X%, Y0#*SF#+Y%, COL%
 NEXT I%
END
Epicycloids This is really more of a gimmick than anything practical. As you can see from the Wikipedia page, an epicycloid is a shape drawn by a circle as it rolls around another circle. To get something which looks pretty, try drawing epicycloids where R0 is a multiple of R1 by some arbitrary K value, such that R0 == R1*K is true. An example of this may be
EPICYCLOID 200,120,(5),(1),6,#RED
Where R0=(5) and R1=(1), and R0 == R1*K is satisfied because 5 == 1*(K=5). In other words, make it so that the first (larger) radii value is an integer multiple of the second (smaller) radii value. Edit: Thanks to 12Me21 for being a math wizard.

nice

You can actually calculate the step value as (1/3)/R0, (I guess it's less descriptive, but it's not entirely obvious how the current method works either) Also, it's more efficient to use FOR I=0 TO 2*PI() ... instead of FOR I=0 TO T ..., because 2*PI() is evaluated during compilation.

Replying to:12Me21
You can actually calculate the step value as (1/3)/R0, (I guess it's less descriptive, but it's not entirely obvious how the current method works either) Also, it's more efficient to use FOR I=0 TO 2*PI() ... instead of FOR I=0 TO T ..., because 2*PI() is evaluated during compilation.
Huh, how did you find (1/3)/R0? I plugged the value in, and it appears to disregard the scale factor involved with plotting the curve. Edit: By also dividing by the scale factor (1/3)/R0/SF, it can plot most of the pixels, but it's still very holey. I just don't really know where the math is coming from, so it's hard to modify.

Replying to:12Me21
You can actually calculate the step value as (1/3)/R0, (I guess it's less descriptive, but it's not entirely obvious how the current method works either) Also, it's more efficient to use FOR I=0 TO 2*PI() ... instead of FOR I=0 TO T ..., because 2*PI() is evaluated during compilation.
oh, forgot about the scale factor. That should be (1/3)/(R0*SF) (What you tried *should* have worked, maybe calculating it that way is less precise, I'm not sure) You calculate the step value as (2*PI()) / (R1*2*PI()*(R0/R1)*SF*3), and if you divide both sides by 2*PI(), you get 1/(R1*(R0/R1)*SF*3) (R0/R1)*R1 is just R0, so you end up with 1/(R0*SF*3), and rewriting this as (1/3)/(R0*SF) uses 1 fewer operation since 1/3 is calculated during compilation. EDIT: I tried 1/3/R0/SF and it seems to work fine... Oh, I almost forgot. You should have a rotation parameter in your function

Replying to:12Me21
You can actually calculate the step value as (1/3)/R0, (I guess it's less descriptive, but it's not entirely obvious how the current method works either) Also, it's more efficient to use FOR I=0 TO 2*PI() ... instead of FOR I=0 TO T ..., because 2*PI() is evaluated during compilation.
Oh, what the heck. Yeah, 1/3/R0/SF works perfectly now. I'm no math wizard, so I just approximated the perimeter as best I could. Thanks!

You shouldn't make X0 and Y0 integers, otherwise it'll get messed up if the scale factor isn't 1

Replying to:12Me21
You shouldn't make X0 and Y0 integers, otherwise it'll get messed up if the scale factor isn't 1
Sorry, but I ninja-edited it before you commented. Realized as soon as I put it to the test.