# Thread: Epitrochoid using Turtle Graphics?

1. Member
Join Date
Oct 2013
Posts
1
Rep Power
0

## 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.

Java 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);

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(); };
}
Last edited by darkzboy; 10-27-2013 at 09:02 PM.

2. Member
Join Date
Oct 2013
Posts
1
Rep Power
0

## 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);
Last edited by Quan; 10-28-2013 at 12:00 AM.

#### Posting Permissions

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