------------------- Shadow of a Quadric ------------------- .. image:: render.png :width: 750px :align: center This example visualizes the shadow of a quadric cast by a light source. You can see the full code at :download:`shadow_of_a_quadric.py <../../../../examples/blender/geometry/shadow_of_a_quadric.py>`. .. contents:: :local: :backlinks: none Setup ===== We start off by importing the necessary libraries. .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [setup-1] :end-before: [setup-1] We are also going to clear the whole scene. .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [setup-2] :end-before: [setup-2] Constants ========= Now we are going to define some constants that we will use later. In particular the data for the images above is given below. .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [constants-1] :end-before: [constants-1] Further define constants for sampling and .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [constants-2] :end-before: [constants-2] Main Construction ================= Now we can begin with the actual construction of this First of all we need a quadric that we create from our initial data. For this example we restrict to quadrics with diagonal matrix. .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [main-construction-1] :end-before: [main-construction-1] Next, let's create the touching cone (or tangent cone) to the quadric from the light source. This is the join of all lines through the point of the light source that are tangent to the quadric, see also :ref:`quadrics`. .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [main-construction-2] :end-before: [main-construction-2] The points where the tangent cone touches the quadric can be determined explicitely. They are given by the intersection of the polar plane of the point of the light source with the quadric. .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [main-construction-3] :end-before: [main-construction-3] Finally we create a projection plane and can explicitly determine the boundary of the shadow by intersecting the tangential cone with the projection plane. .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [main-construction-4] :end-before: [main-construction-4] Visualization ============= With all this we can now visualize everything in Blender. Note that we have not assigned materials in this example. We start with the quadric and, for the one-sheeted hyperboloid example, its generators. The generators are determined in the following way. Take a conic section of the hyperboloid, for example the intersection with the polar plane from above. Convert it to a (`SmoothNet` and then to a) `DiscreteNet` using a rational multible of `np.pi` as a sampling. This gives a uniform, closed sampling of points on the conic section. One can use a traverser to iterate through the domain of the discrete curve an thus through the points on the conic. The polar plane of a (projective) point `x` on the conic is the tangent plane at `x` and intersects the hyperboloid in two generators, meeting in `x`. These we can visualize. .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [visualization-1] :end-before: [visualization-1] Next, we will create a camera and a light source. The light sits at the apex of the touching cone and we let it shine parallel to the axis of the cone. .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [visualization-2] :end-before: [visualization-2] Now we are going to visualize one half of the cone. .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [visualization-3] :end-before: [visualization-3] The next step is to add the projection plane and the boundary of the shadow. .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [visualization-4] :end-before: [visualization-4] And finally, we create the polar plane and its intersection. .. literalinclude:: ../../../../examples/blender/geometry/shadow_of_a_quadric.py :language: python :start-after: [visualization-5] :end-before: [visualization-5]