Advertisement
Advertisement
| 02.11.2008 at 06:58AM PST, ID: 23153102 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: |
import java.awt.*;
import javax.swing.*;
import javax.media.opengl.*;
public class ductranhw1 extends J1_0_Point {
double centerX = WIDTH / 2, centerY = HEIGHT / 2, radius = WIDTH / 3, theta = 0;
double delta = 4 / (Math.PI * radius);
public ductranhw1() {
capabilities.setDoubleBuffered(true);
}
public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
// draw circle
gl.glColor3f(1.0f, 1.0f, 1.0f);
gl.glPointSize(4);
drawCircle(centerX, centerY, radius);
for (int i = 0; i < 50; i++) {
//draw red point
theta = theta + delta;
double x = radius * Math.cos(theta) + centerX;
double y = radius * Math.sin(theta) + centerY;
gl.glPointSize(10);
gl.glColor3f(1.0f, 0.0f, 0.0f);
try {
drawPoint(x, y);
Thread.sleep(10);
} catch (Exception ignore) {
}
}
}
public static void main(String[] args) {
ductranhw1 frame = new ductranhw1();
frame.setTitle("Duc Tran Minh Homework1");
frame.setSize(WIDTH, HEIGHT);
frame.setVisible(true);
}
private void drawCircle(double centerX, double centerY, double radius) {
double th = 0;
while (th <= 2 * Math.PI) {
th = th + delta;
double x = radius * Math.cos(th) + centerX;
double y = radius * Math.sin(th) + centerY;
drawPoint(x, y);
}
}
private void drawPoint(double x, double y) {
gl.glBegin(GL.GL_POINTS);
gl.glVertex2d(x, y);
gl.glEnd();
}
}
|