Results 1 to 2 of 2
 10272013, 08:51 PM #1Member
 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.
Can anyone please help?
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; //xcoordinate double y; //ycoordinate(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(); }; }
Last edited by darkzboy; 10272013 at 09:02 PM.
 10272013, 11:38 PM #2Member
 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; 10282013 at 12:00 AM.
Similar Threads

turtle graphics
By Kareem Mesbah in forum New To JavaReplies: 1Last Post: 10202012, 08:15 PM 
"turtle game" 4 different classes  trouble moving the turltes __
By gcap in forum New To JavaReplies: 1Last Post: 12092011, 02:18 PM 
Downloading Turtle Graphics and Other Packages
By Godsarmy4vr2 in forum New To JavaReplies: 4Last Post: 02282010, 07:19 PM 
Turtle assignment
By jmc724 in forum New To JavaReplies: 11Last Post: 07162008, 09:11 PM
Bookmarks