Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

Members have full access to the forums. Advertisements are removed for registered users.

# Thread: A very very simple 3D rendering routine (Almost) - Seeking Help with my code

1. ## A very very simple 3D rendering routine (Almost) - Seeking Help with my code

I've been working on this project. The goal is to provide simple routines to project objects in 3D space onto a 2D camera screen. I have found and used sources from the internet to perform some of the calculations. I have attached a screenshot of the output thus far and the project files as created in Net Beans.

The attached pic may look correct but I do believe its wrong in the fact that its looks lopsided. To debug the program I have first confirmed that the intercept points are correct on the camera screen. From there I have found that there might be an error in how the program calculates the distance of a 3D point to a plane which is used on the camera screen.

public double point_plane_distance(Vector3D point)
{
double e = ((a * point.x) + (b * point.y) + (c * point.z)-d) / Math.sqrt(Math.pow(a,2) + Math.pow(b,2) + Math.pow(c,2));

return e;
}

double x_dist = vertical_offset.point_plane_distance(ip);
double y_dist = horizontal_offset.point_plane_distance(ip);

System.out.println("x dist to screen offset: " + x_dist);
System.out.println("y dist to screen offset: " + y_dist);

***

What I'm looking for is help from other programmers to validate the code and provide feedback on if its actually correct and to provide a solution otherwise. Please feel free to download and unzip the attached source for review.

Russell Brown
Toronto Ontario