------------------------------ Three triangles in perspective ------------------------------ .. image:: render.png :width: 750px :align: center Triangles are said to be in perspective with respect to a point if the three lines through corresponding points are concurrent (intersect in one point, red triangles). The resulting point is called the *center of perspectivity*. Two triangles are said to be *in perspective with respect to a line* if the three intersection points of corresponding lines are collinear. The resulting line is called the *axis of perspectivity* (three blue lines, one for each pair of triangles). Desargues Theorem states, that two triangles are in perspective with respect to a point if and only if they are in perspective with respect to a line. For three triangles in perspective, it can be shown that the three axes of perspectivity are concurrent. The 3d configuration can be projected to a 2d plane. Source code: :download:`three_triangles_in_perspective.py <../../../../examples/blender/geometry/three_triangles_in_perspective.py>`. .. contents:: :local: :backlinks: none Setup ===== We start off by importing the necessary libraries and clearing the scene. .. literalinclude:: ../../../../examples/blender/geometry/three_triangles_in_perspective.py :language: python :start-after: [setup-1] :end-before: [setup-1] Next we initialize some data: one point of perspectivity, three directions for the lines of perspectivity (where vertices of the triangles lie on), and for each vertex of a triangle a distance that defines the position of the vertex on the line of perspectivity. Further, for producing a shadow we set initial data that defines a center of projection (the location of the light source), and a projection plane. The data given in this example will produce the picture above. .. literalinclude:: ../../../../examples/blender/geometry/three_triangles_in_perspective.py :language: python :start-after: [setup-2] :end-before: [setup-2] With the given initial data we can create the lines of perspectivity as projective subspaces. .. literalinclude:: ../../../../examples/blender/geometry/three_triangles_in_perspective.py :language: python :start-after: [setup-3] :end-before: [setup-3] Geometric Calculations ====================== The three triangles can be constructed in different ways using the distances given in the initial data. Here we show two possible ways where in both cases a resulting triangle will be represented as a list of three points. .. literalinclude:: ../../../../examples/blender/geometry/three_triangles_in_perspective.py :language: python :start-after: [construction-1] :end-before: [construction-1] Now we are able to construct the edges as subpspaces, intersect corresponding lines, construct the axes of perspectivity and intersect those. .. literalinclude:: ../../../../examples/blender/geometry/three_triangles_in_perspective.py :language: python :start-after: [construction-2] :end-before: [construction-2] In order to construct the light blue segments as in the picture we need to initialize those subspaces in a specific way. Each light blue segment contains four points: two corresponding to an edge of a triangle and two lying on the axes of perspectivity. One can determine the outer ones, for example by computing signed distances, use them to construct a line, and visualize this line using `domain=[[0,1]]`. .. literalinclude:: ../../../../examples/blender/geometry/three_triangles_in_perspective.py :language: python :start-after: [construction-3] :end-before: [construction-3] Finally, we add a projection plane to catch the shadow. .. literalinclude:: ../../../../examples/blender/geometry/three_triangles_in_perspective.py :language: python :start-after: [construction-4] :end-before: [construction-4] Visualization ============= Again we start with a block of initial data for our This allows an easy change of parameters. Further we need a utility function to visualize a triangle, here a halfedge object is created and then visualized. .. literalinclude:: ../../../../examples/blender/geometry/three_triangles_in_perspective.py :language: python :start-after: [visualization-1] :end-before: [visualization-1] Now we can visualize all our objects, .. literalinclude:: ../../../../examples/blender/geometry/three_triangles_in_perspective.py :language: python :start-after: [visualization-2] :end-before: [visualization-2] and add a light and a camera. .. literalinclude:: ../../../../examples/blender/geometry/three_triangles_in_perspective.py :language: python :start-after: [visualization-3] :end-before: [visualization-3] Finally these are the rendering setting used in this example. .. literalinclude:: ../../../../examples/blender/geometry/three_triangles_in_perspective.py :language: python :start-after: [visualization-4] :end-before: [visualization-4] That's it! You should be able to just put that in your blender code editor and simply execute it. Hit the render button to render the image at the top.