Implementation#
This section provides an in-depth look at the workings of axonometry, delving into how its core functionality was designed and implemented. Furthermore, it reveals the design decisions that underpin the library’s alignment with the broader context of architectural representation.
Note
When reviewing subsequent listings, note that redundant imports have been omitted for each listing to focus on key concepts rather than being entire working scripts.
Coordinate Spaces#
World coordinate space vs. View plane coordinate system.
(This is where axonometry is a practical counter-point to GC principles)
Coordinate Plane Tilts#
or: How did this become a library ?
Trihedron#
The trihedron is working behind the scene to set up the coordinate axes and to calculate the tilts of the coordinate planes producing the reference planes.
Once givent the axes angles and the reference trihedron being constructed, the goal is to find the position of the reference planes. This process can be done algebraicly with some trigonometry. [1]
Reference Planes#
What are they good for ? Computing their local matrix in order to draw in them.
Class Diagram#
Axonometryhas a relationship with Trihedron, Plane, and Drawing:When an
Axonometryinstance is created with specific angles, position, size, and distance for reference planes.Initializes a
Trihedronwhich will set up reference planes (ReferencePlane), and assigns them to the drawing object.The Axonometry class uses methods like draw_line to add lines to the appropriate plane based on its key.
Initializes a
Drawingwhich will be assigned to all threeReferencePlane.
Planeis an abstract base class for bothAxonometry(which represents the axonometric plane) and theReferencePlane(which represents a tilted coordinate plane):The class has properties to collect and access the points and lines contained in the plane
The class has the
draw_point()anddraw_line()to add these geometric objects.
Trihedronis responsible for setting up the coordinate system with axes:It creates the three reference planes (
ReferencePlane) and stores them in a dictionary.The trihedron object provides access to these reference planes via properties like xy, yz, and zx.
ReferencePlane:Inherits from Plane. Represents a reference plane in the tilted coordinate system.
Initializes with two axes (Line) and a projection vector. It has methods for adding SVG files and handling projections.
Drawingis responsible for recording all drawing and projection operations:Instances of Drawing are initialized within Axonometry and can add points and lines to the embedded VPype document or scene.
add_compas_geometry is a shortcut to add geometries directly to the drawing object. It is used to record traces of the projections. As these traces do not need to be part of the
Projectile.projectionsandPlane.objectscollections.
Elements#
On a high level principle, the implementation is straight forward. The basic element is the point. On a user-level, a point is made up of three values: it’s x, y and z coordinates. Internally, the graphic elements have to exist as a twin in the view plane coordinate system. For that puropse is used the compas library. The objects used from compas are defined with a C prefix: CPoint, CLine, CVector etc.
Point#
The point object is made of three coordinates. Depending in which plane the point is contained, a certain compas Point is computed and assigned as the Point.data attribute to the point. One can add a point in the axonometric picture plane or in one of the reference planes.
Line#
The line is made with two points, Line.start, Line.end. The general case is to initialize a compas Line with the two points’ data attribute as parameters.
Projection Planes#
The first step is to have our four planes in which we can add geometry.
The basic structure of the library is to be able to add geometry to planes, and to project geometries from one plane on another.
The Plane is where geometry can be added.
Drawing#
Valid angles#
Check if angles satisfy the following conditions:
not (180 - (alpha + beta) >= 90 and
not (alpha == 0 and beta == 0) and
not (alpha == 90 and beta == 0) and
not (alpha == 0 and beta == 90)
This condition is implemented as a test in the function is_valid_angle_pair().