Wednesday, December 14, 2011

Pedagogy Y


One should calculate the Y-dimension of each object in a well-written sentence. This is shown by the following algorithm depth/8, which calculates the depth of a point in a cube.
1. depth(EdgeLength, X0, Y0, X1, Y1, X2, Y2, Depth) :-
2.     Length1 is sqrt((X1 - X0) ^ 2 + (Y1 - Y0) ^ 2),
3.     Length2 is sqrt((X2 - X0) ^ 2 + (Y2 - Y0) ^ 2),
4.     Depth is (Length2 / Length1) * EdgeLength.
Line 1. Given the image of the length of a cube's edge, its origin (X0, Y0), the location in the image of its back-bottom-left point (X1, Y1), and a point on the line between the front-bottom-left to the back-bottom-left point (X2, Y2), the algorithm calculates the depth (y co-ordinate) of point 2.  Note: this y co-ordinate is the actual 3D co-ordinate, which is different from the type used in the algorithm, which are those of a 2D front view of a 3D-object.
Line 2. Given the Pythagorean formula C2 = A2 + B2, written in the form C = sqrt(A2 + B2) by finding the square root of both sides, the algorithm finds the hypotenuse (side opposite the right angle) in the triangle.  Note, this is where e.g. A is the length of one side, which equals X1 - X0.  So, this length of the 2D image of the line between the front-bottom-left to the back-bottom-left point of the cube is Length1.
Line 3. Calculates the length of the 2D image of the line between the point on the line between the front-bottom-left and the back-bottom-left point of the cube, which is Length2.
Line 4. Calculates the 3D y co-ordinate as the fraction Length2 / Length1, multiplied by the  cube’s edge length.

No comments:

Post a Comment