Triangle64

giant.ray_tracer.shapes.triangle:

class giant.ray_tracer.shapes.triangle.Triangle64(self, vertices, albedos, facets, normals=None, compute_bounding_box=True, bounding_box=None, compute_reference_ellipsoid=True, reference_ellipsoid=None)

This class represents surfaces as tessellated triangles, storing the vertices, albedos, and normal vectors using double precision.

The surface is comprised of a vertices array, which is a nx3 double precision array specifying the vertices for the surface in the current frame, an albedos double precision nx3 array or scalar representing the albedo for each vertex (if a scalar, then every vertex has the same albedo), a normals mx3 double precision array representing the normal vector for each triangle, and a facets mx3 facet map which indexes into the vertices and albedos arrays to specify the triangles. Note that here we assign the albedo to each vertex, not each face as is commonly done in other rendering programs. When tracing, we then use linear interpolation to calculate the albedo at the intersect point based on the albedos of the vertices of the triangle we intersected.

To use this class you must provide at minimum the vertices, albedos, and facets, which result in the normals being computed for you. In addition, when initializing the class, you can provide (or have automatically computed) an axis aligned bounding box which contains all of the represented surface and a reference ellipsoid which describes the tri-axial ellipsoid which best represents the surface. Both of these are optional though.

Once initialized, you can use this class for ray tracing as well as for identifying limbs and limb jacobians. That being said, you typically should accelerate these things using the KDTree class, which will result in much better performance.

Note that beyond using double precision, this is identical to the Triangle32 class.

Parameters:
  • vertices (ARRAY_LIKE) – The vertices for the surface as a n by 3 array

  • albedos (Union[ARRAY_LIKE, float]) – The albedo(s) for the surface as either a scalar or a length n array

  • facets (ARRAY_LIKE) – The connectivity map for the surface as a mxp array where m is the number of faces, p is the number of vertices for each face, and each element is an index into the vertices array

  • normals (Optional[ARRAY_LIKE]) – The normal vectors for each face of the surface. If None then the normals will be computed

  • compute_bounding_box (Optional[AxisAlignedBoundingBox]) – A flag specifying whether to compute the axis aligned bounding box for the surface

  • bounding_box – The axis aligned bounding box for the surface. This will be overwritten if compute_bounding_box is True

  • compute_reference_ellipsoid (bool) – A flag specifying whether to compute the reference ellipsoid for the surface.

  • reference_ellipsoid (Optional[Ellipsoid]) – The reference ellipsoid for the surface. If compute_reference_ellipsoid is True this will be overwritten

bounding_box: AxisAlignedBoundingBox

The AxisAlignedBoundingBox that fully contains this solid.

reference_ellipsoid: Ellipsoid

The Ellipsoid that best represents the surface.

albedos

This property represents the albedo for the surface.

The albedo can either be a scalar, if there is a single albedo for the entire array, or an array of length n if there is a different albedo value for each vertex. Both are accessed through this property

facets

This property returns the facets for the surfaces(s) as a mx3 ndarray where each face has 3 vertices and there are m faces overall.

The facet elements are indices into the vertices array. They must be positive.

Each row of this array corresponds to the same row of the normals array

normals

This property returns the normals for the surfaces(s) as a mx3 ndarray where there are m surfaces contained

Each row of this array corresponds to the same row in the facets array.

num_faces

The number of faces in this surface.

This is the length of the first axis of the facets array.

sides

This property calculates the primary sides of the surface as a mx3x2 ndarray where each surface has 2 primary sides and there are m surfaces overall

Returns:

The primary sides of the surface

Return type:

np.ndarray

stacked_vertices

This property returns the vertices for the surfaces(s) as a mx3xp ndarray where each surface has p vertices and there are m surfaces overall.

This returns self.vertices[self.facets].swapaxes(-1, -2). Note that this will always produce a copy, so be cautious about using this property frequently

vertices

This property returns the vertices for the surfaces as a nx3 ndarray where there are n vertices.

The facets array indexes into the row axis of this array

Summary of Methods

compute_bounding_box

This method computes the bounding box that contains all of the vertices.

compute_intersect

This method computes the intersects between a single ray and the surface describe by this object.

compute_limb_jacobian

This method computes the linear change in the limb location given a change in the relative position between the surface and the observer.

compute_normals

This method computes the unit normal vectors for each facet.

compute_reference_ellipsoid

This method computes the reference ellipsoid that best represents the vertices.

find_limbs

This method determines the limb points for a surface (visible edge of the surface) that would be visible for an observer located at observer_position looking toward scan_center_dir along the directions given by scan_dirs.

get_albedo

This method computes the albedo for a given intersect point and intersect face.

merge

This method is used to merge two surface collections together.

rotate

This method rotates the surface into a new frame.

trace

This python method provides an easy interface to trace a number of Rays through the surface.

translate

This method translates the surface