This implementation of the Component class is the representation of a surface using triangle elements.
This is supposed to be the standard element in pyvsim, as raytracing with such surfaces is relatively easy and plotting is also made easy by using libraries such as VTK, Matplotlib and OpenGL.
Another benefit is the possibility of directly reading this topology from a STL file, that can be exported from a CAD program.
It is important to notice that the triangle definition defines a series of behaviors within pyvsim, such as defining whether a ray is entering or leaving a body.
The definition of a triangle is given in the figure below:
And it is important to remember that in a closed surface, the normal always points outwards.
Methods
Returns the coordinates of the aligned-to-axis-bounding box
Returns : | bounds : numpy.ndarray \((6)\)
|
---|
Implement this method whenever your object possesses geometrical features that are calculated from their interaction with the ambient (e.g. - any raytraced features). This method is called after all spatial transformations
Part color
The connections between points defining triangles. Given as an \((N,3)\) array of indexes of points. The order of definition affects the direction of the triangle normal
Field for storing extra data about the part
This is a method used specifically for ray tracing. The method returns data about the first intersection between line segments and the polygons defined in the Component. The implementation of the intersection is given by the inheriting classes.
This method is intended for use in raytracing algorithms, as there is an initial, fast verification to see if there is a chance of any triangle in the polygon to be intersected, then, if it is the case, it executes expensive search.
Special cases when intersecting with individual triangles:
Algorithm adapted from http://geomalgorithms.com/a06-_intersect-2.html
Parameters : | p0, p1 - numpy.ndarray :math:`(N,3)` :
tol - double :
|
---|---|
Returns : | None :
lineParameter :
intersectionCoordinates :
triangleIndexes :
normals :
part :
|
Material of the part (initialized as IdealMaterial(1))
Stores each triangle normal vector in a \((N,3)\) array
Part opacity
A \((N,3)\) array containing the coordinates of the part points
Returns the index of refraction of the material given the wavelength (or a list of them)
Parameters : | wavelength : scalar or numpy.ndarray
|
---|---|
Returns : | refractiveIndex : same dimension as wavelength
|
This method is in charge of updating the position of the point cloud (provided it exists) when the Part is rotated.
There is an exception handling because there is the possibility that the part is translated before the points are defined. This is extremely unlikely, but should not stop the program execution.
In case the surface is defined with normals on vertices (thus making self.normals not None), these vectors are rotated.
Parameters : | angle :
axis : numpy.ndarray \((1,3)\)
pivotPoint : numpy.ndarray \((1,3)\)
|
---|
Surface property (initialized as Component.OPAQUE)
This method is in charge of updating the position of the point cloud (provided it exists) when the Part is translated.
There is an exception handling because there is the possibility that the part is translated before the points are defined. This is extremely unlikely, but should not stop the program execution.
Parameters : | vector : numpy.ndarray \((1,3)\)
|
---|
Toggles visibility