Package theia :: Package helpers :: Module geometry
[hide private]
[frames] | no frames]

Module geometry

source code

Geometry module for theia.

Functions [hide private]
 
refrAngle(theta, n1, n2)
Returns the refraction angle at n1/n2 interface for incoming theta.
source code
 
linePlaneInter(pos, dirV, planeC, normV, diameter)
Computes the intersection between a line and a plane.
source code
 
lineSurfInter(pos, dirV, chordC, chordNorm, kurv, diameter)
Computes the intersection between a line and a spherical surface.
source code
 
lineCylInter(pos, dirV, faceC, normV, thickness, diameter)
Computes the intersection of a line and a cylinder in 3D space.
source code
 
newDir(inc, nor, n1, n2)
Computes the refl and refr directions produced by inc at interface n1/n2.
source code
 
rotMatrix(a, b)
Provides the rotation matrix which maps a (unit) to b (unit).
source code
 
basis(a)
Returns two vectors u and v such that (a, u, v) is a direct ON basis.
source code
 
rectToSph(array)
Returns the spherical coordinates of the unitary vector given by array.
source code
Variables [hide private]
  __package__ = 'theia.helpers'
Function Details [hide private]

refrAngle(theta, n1, n2)

source code 

Returns the refraction angle at n1/n2 interface for incoming theta.

May raise a TotalReflectionError.

linePlaneInter(pos, dirV, planeC, normV, diameter)

source code 
Computes the intersection between a line and a plane.

pos: position of the begining of the line. [3D vector]
dirV: directing vector of the line. [3D vector]
planeC: position of the center of the plane. [3D vector]
normV: vector normal to the plane. [3D vector]
diameter: diameter of the plane.

Returns a dictionary with keys:
    'isHit': whether of not the plane is hit. [boolean]
    'distance': geometrical distance from line origin to intersection point.
        [float]
    'intersection point': position of intersection point. [3D vector]

lineSurfInter(pos, dirV, chordC, chordNorm, kurv, diameter)

source code 
Computes the intersection between a line and a spherical surface.

The spherical surface is supposed to have a cylindrical symmetry around
    the vector normal to the 'chord', ie the plane which undertends
    the surface.

Note: the normal vector always looks to the center of the sphere and the
    surface is supposed to occupy less than a semi-sphere

pos: position of the begingin of the line. [3D vector]
dirV: direction of the line. [3D vector]
chordC: position of the center of the 'chord'. [3D vector]
chordNorm: normal vector the the chord in its center. [3D vector]
kurv: curvature (1/ROC) of the surface. [float]
diameter: diameter of the surface. [float]

Returns a dictionary with keys:
    'is Hit': whether the surface is hit or not. [boolean]
    'distance': distance to the intersection point from pos. [float]
    'intersection point': position of intersection point. [3D vector]

lineCylInter(pos, dirV, faceC, normV, thickness, diameter)

source code 
Computes the intersection of a line and a cylinder in 3D space.

The cylinder is specified by a disk of center faceC, an outgoing normal
normV, a thickness (thus behind the normal) and a diameter.

pos: origin of the line. [3D vector]
dirV: directing vector of the line. [3D vector]
faceC: center of the face of the cylinder where lies the normal vector.
    [3D vector]
normV: normal vector to this face (outgoing). [3D vector]
thickness: thickness of the cylinder (counted from faceC and behind normV)
    [float]
diameter: of the cylinder. [float]

Returns a dictionary with keys:
    'isHit': whether of not. [boolean]
    'distance': geometrical distance of the intersection point from pos.
        [float]
    'intersection point': point of intersection. [3D vector]

newDir(inc, nor, n1, n2)

source code 
Computes the refl and refr directions produced by inc at interface n1/n2.

inc: director vector of incoming beam. [3D vector]
nor: normal to the interface at the intersection point. [3D vector]
n1: refractive index of the first medium. [float]
n2: idem.

Returns a dictionary with keys:
    'r': normalized direction of reflected beam. [3D vector]
    't': normalized direction of refracted beam. [3D vector]
    'TR': was there total reflection?. [boolean]

Note: if total reflection then refr is None.

rotMatrix(a, b)

source code 

Provides the rotation matrix which maps a (unit) to b (unit).

a,b: unit 3D vectors. [3D np.arrays]

Returns an np.array such that np.dot(M,a) == b.

rectToSph(array)

source code 

Returns the spherical coordinates of the unitary vector given by array.

array: 3D vector (unitary). [float]

Returns the theta and phi angles in radians with theta in [0, pi] and phi in [-pi, pi]