|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionI got a requirement to plot a list of 3D points on a graphics display. The list of points is generated by some other software. I had to do this using Dot Net. I am not using DirectX or any other library. I have created a 3D Geometry library with just basic classes like Vector, Matrix and Point. A test application also has been developed to test this library. The test application reads a point data file and draws lines connecting the read points. It also has options to view the 3D object along different axes. I have done these using VB.Net 2.0. Geometry Library (Basic classes)This geometry library contains only some basic classes like Vector, Matrix and Point. I have created two classes 2D and 3D for each of these. (Vector2D, Vector3D, Matrix2D, Matrix3D, Poin2D and Point3D). The 2D classes are used for two-dimensional geometry and 3D classes for three-dimensional geometry. You can get more detailed explanations about Geometry, Vector and Matrix functionalities by searching on the web. PointA Point represents a 2 dimensional or 3 dimensional point in space. A Point is represented by its X and Y (also Z in case of 3D point) coordinates. VectorA Geometrical Vector specifies the direction in space. The
Vector has two properties Length and Direction. The Vector does not have a
fixed location in space. Our Vector classes have standard vector operations like Addition, Subtraction, Transformation, Negation, Dot Product, Cross Product, finding the angle between two vectors etc. MatrixMatrices allow arbitrary linear transformations to be represented in a consistent format, suitable for computation. This also allows transformations to be concatenated easily by multiplying their matrices – from wikipedia. We use a 3x3 matrix for 2D and 4x4 matrix for 3D. You can find more information by searching on the web. I have created specific Matrix classes for 2D and 3D for convenience. Alternatively a generic Matrix class can be created and 2D and 3D Matrix classes can be derived from the generic class. Our Matrix classes have standard matrix operations like Multiplication, Get the inverse of the matrix, Get the rotation, scaling and transformation matrices etc. Using the 3D matrix class: ' create a new
instance, which creates a identity matrix Test ApplicationThe test application reads a point data file and draws lines
connecting the list of points. The file contains a list of 3D points. The X, Y
and Z coordinates are separated by spaces and each point is stored in new
lines. 0.0 0.0 0.0 The functions 'PointReader' and 'ReadPointFromString' parse
the data file and fill the points array. In this example data file, the points
are manipulated to get the desired result. But the original requirement was to
plot the points on the screen. But for demonstrating the geometry library, I
have considered drawing lines, to show a 3D shape object. Looking at various viewsFunctionalities of the test application include viewing the 3D object from X-axis, Y-axis, Z-axis and 3D view. ![]() 3D View View from X
View from Y
View from Z For example, to get the view from X direction, first we transform the points to the original position, then create the required matrix object and transform the points to the required position. ' set the
drawing to initial position (looking from Z) I am using the panel control for drawing the graphics. Using the double buffer concept to avoid flickering, when the graphics refreshes (http://www.thescripts.com/forum/thread267635.html).
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||