# Epitrochoid using Turtle Graphics?

• 10-27-2013, 08:51 PM
darkzboy
Epitrochoid using Turtle Graphics?
Link to question: Fundamentals of Computer Science Using Java - David Hughes - Google Books
Question 42.

How would one get started on this? I've looked at all my examples from my labs and cannot seem to figure this one out for the life of me, I've even asked a couple of people in the course on facebook, and they all just tell me to 'skip the question'.

I figured I start by figuring out the code for the inner loop and the outer loop.. but its still not working.

Code:

```package Epitrochoid; import Media.*; // for displayer and turtle import java.awt.*; // for Color class import static java.lang.Math.*; // for math constants, functions & random import static Media.Turtle.*; // for turtle speed constants import static java.awt.Color.*; // for Color constants public class Epitrochoid {   private TurtleDisplayer display; // display to draw on   private Turtle          yertle; // turtle to do drawing  // Instance variable declarations    public Epitrochoid ( ) {   display = new TurtleDisplayer();   yertle = new Turtle(Turtle.FAST);   display.placeTurtle(yertle);     yertle.penDown();   drawEpitrochoid();   }; // constructor      private void drawEpitrochoid ( double a, double b, double k, int num ) {   double x; //x-coordinate   double y; //y-coordinate(y= f(x))   int t;       yertle.right(angle);   yertle.forward(radius);     for ( t=1 ; t<=num ; t++ ) {       t = 1/num;       x = (a+b)*cos(2*PI*t) - k * cos(2*PI*(a+b)*(t/b));       y = (a+b)*sin(2*PI*t) - k * sin(2*PI*(a+b)*(t/b));       yertle.moveTo(x,y);   }; }; // drawEpitrochoid            public static void main ( String[] args ) { Epitrochoid v = new Epitrochoid(); }; }```
• 10-27-2013, 11:38 PM
Quan
Re: Epitrochoid using Turtle Graphics?
Random question... do you attend Brock?

EDIT: Actually, that was a dumb question, just saw the "David Hughes" bit... you're practicing for the lab test, yes?
(just curious because I am doing the same thing...*cough*)

EDIT 2: off the top of my head, should you not be initializing a, b etc in the public class?
e.g double a = 50;
double b = etc.

yertle.penDown();
drawEpitrochoid( a, b, k, num);