2 Attachment(s)

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