--------------------------- Lines in a Projective Plane --------------------------- .. image:: render.png :width: 750px :align: center In this example we will generate random lines (represented as planes) in a projective plane and visualize their intersections with a sphere and the projective plane in a Blender 3D scene. It's a combination of geometric calculations and Blender scripting for You can see the full code at :download:`lines_in_a_projective_plane.py <../../../../examples/blender/geometry/lines_in_a_projective_plane.py>`. .. contents:: :local: :backlinks: none Setup ===== We start off by importing the necessary libraries. .. literalinclude:: ../../../../examples/blender/geometry/lines_in_a_projective_plane.py :language: python :start-after: [setup-1] :end-before: [setup-1] We are also going to clear the whole scene. .. literalinclude:: ../../../../examples/blender/geometry/lines_in_a_projective_plane.py :language: python :start-after: [setup-2] :end-before: [setup-2] Blender Collections =================== We create three Blender collections: ``rendering_coll`` for lights and cameras, ``gc_coll`` for great circles, and ``plane_coll`` for plane intersections. .. literalinclude:: ../../../../examples/blender/geometry/lines_in_a_projective_plane.py :language: python :start-after: [blender-collections] :end-before: [blender-collections] Geometric Calculations ====================== Now we are going to generate random points on a unit sphere and calculate the corresponding planes using these points as normals. These planes are represented in the projective space. .. literalinclude:: ../../../../examples/blender/geometry/lines_in_a_projective_plane.py :language: python :start-after: [geometric-calculations-1] :end-before: [geometric-calculations-1] Next we create a unit sphere (:math:`S^2`) and a projective plane. The sphere is represented as a quadric, and the projective plane is represented as a hyperplane. .. literalinclude:: ../../../../examples/blender/geometry/lines_in_a_projective_plane.py :language: python :start-after: [geometric-calculations-2] :end-before: [geometric-calculations-2] Geometric Intersections ======================= For each randomly generated plane, we calculate the intersection of the plane with the sphere (``circ_on_sphere``) and the intersection with the projective plane (``meet_plane``). These intersections are then visualized. .. literalinclude:: ../../../../examples/blender/geometry/lines_in_a_projective_plane.py :language: python :start-after: [geometric-intersections-1] :end-before: [geometric-intersections-1] Finally we can visualize it in Blender. .. literalinclude:: ../../../../examples/blender/geometry/lines_in_a_projective_plane.py :language: python :start-after: [geometric-intersections-2] :end-before: [geometric-intersections-2] Add Camera and Light ==================== Awesome, so if we run this now, we see something in the Editor! However, for rendering we need a camera and a light. Let's add those. .. literalinclude:: ../../../../examples/blender/geometry/lines_in_a_projective_plane.py :language: python :start-after: [add-camera-and-light] :end-before: [add-camera-and-light] Add Materials ============= Finally let's assign materials to the projective plane and the sphere. We assign the projective plane a color. .. literalinclude:: ../../../../examples/blender/geometry/lines_in_a_projective_plane.py :language: python :start-after: [add-materials-1] :end-before: [add-materials-1] The sphere will get a color with transparency. .. literalinclude:: ../../../../examples/blender/geometry/lines_in_a_projective_plane.py :language: python :start-after: [add-materials-2] :end-before: [add-materials-2] That's it! You should be able to just put that in your blender code editor and simply execute it.