<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Basic spatial data
March 2018, June 2019. Mauro Alberti.
Last version
Step1:  1. Introduction
gsf is a library for the processing of geometric and geographic data, with a focus on structural geology data. It is composed by a Python 3 module, pygsf, and an experimental, still in progress Haskell module, named hsgsf. This notebook will present the Python version.
Since we will plot geometric data into stereonets, prior to any other operation, we import mplstereonet and run the IPython command %matplotlib inline, that allows to incorporate Matplotlib plots in the Jupyter notebook.
Step2:  We import all classes/methods from the geometry sub-module
Step3:  2. Basic spatial data types
Step4:  When considering two points, we can calculate their 3D distance as well as their horizontal, 2D distance
Step5:  Among other methods, we can
Step6:  The four coefficient returned (a, b, c and d) define the Cartesian plane as in the equation
Step7:  In this example the normal versor is vertical.
We can calculate the intersection, expressed as a versor, between two Cartesian planes
<ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 1
Explanation: Basic spatial data
March 2018, June 2019. Mauro Alberti.
Last version: 2021-04-04
Last running version: 2021-04-24
Developement code:
End of explanation
%matplotlib inline
Explanation: 1. Introduction
gsf is a library for the processing of geometric and geographic data, with a focus on structural geology data. It is composed by a Python 3 module, pygsf, and an experimental, still in progress Haskell module, named hsgsf. This notebook will present the Python version.
Since we will plot geometric data into stereonets, prior to any other operation, we import mplstereonet and run the IPython command %matplotlib inline, that allows to incorporate Matplotlib plots in the Jupyter notebook.
End of explanation
from pygsf.geometries.shapes.space3d import *
Explanation: We import all classes/methods from the geometry sub-module:
End of explanation
p1 = Point3D(1.0, 2.4, 0.2)  # definition of a PPoint3Doint instance
Explanation: 2. Basic spatial data types: points and planes
The reference axis orientations used in pygsf are the x axis parallel to East, y parallel to North and z vertical, upward-directed. 
2.1 Cartesian points
A point is created by providing three Cartesian coordinates:
End of explanation
p2 = Point3D(0.9, 4.2, 10.5)
p1.distance(p2)  # 3D distance between two points
Explanation: When considering two points, we can calculate their 3D distance as well as their horizontal, 2D distance:
End of explanation
pl1 = CPlane3D.fromPoints(Point3D(0, 0, 0), Point3D(1, 0, 0), Point3D(0, 1, 0))
print(pl1)
Explanation: Among other methods, we can:
 - translate the point position by providing three offset cartesian values (x, y and z) or directly via a vector;
 - check if two points are within a given range of each other;
 - convert a point to a vector.
2.2 Cartesian planes
A Cartesian plane can be defined in a few different ways, with the simplest one by providing three points within the plane:
End of explanation
normal_versor = pl1.normVersor()  # versor (unit vector) normal to the provided Cartesian plane
print(normal_versor)
Explanation: The four coefficient returned (a, b, c and d) define the Cartesian plane as in the equation: 
ax + by + cz = d
For the given example, the equation is satisfied for all x and y values provided z is zero. We are therefore considering a horizontal plane passing through the frame origin.
The versor normal to a Cartesian plane is obtained by the method:
End of explanation
pl1, pl2 = CPlane3D(1, 0, 0, 0), CPlane3D(0, 0, 1, 0)
inters_v = pl1.intersVersor(pl2)  # intersection versor between two Cartesian planes 
print(inters_v)
Explanation: In this example the normal versor is vertical.
We can calculate the intersection, expressed as a versor, between two Cartesian planes:
End of explanation
<END_TASK>