Geometry

Structures from shapes, discretised into expressions; see the tutorial example 7 and “Defining complicated structures” in the old manual. In 2D (Geometry) the first coordinate is the propagation direction.

2D

class camfr.Geometry(background_mat=Isotropic n=(1, 0))

A 2D structure built from shapes, discretised into a Stack expression.

g = Geometry(background), then g += Rectangle(...) etc.; shapes added later take precedence where they overlap. g.to_expression(...) gives the Expression for a Stack.

add(s)
to_expression(x0, x1, dx=0, y0=0, y1=0, dy=0, add_flipped=0, calc_average=0, verbose=False, rescaling='ANTIALIAS')

Discretise the geometry into an Expression of Slabs.

x0..x1 is the range along the propagation direction, cut into slices dx long; y0..y1 the transverse range. Neighbouring slices are merged when their material boundaries differ by less than dy, so slowly varying regions get fewer, thicker slices. add_flipped appends the mirrored expression; calc_average also returns the average eps and 1/eps. For a Picture, x0, x1 convert pixels to lengths and dx sets the resolution (0: one slice per pixel column); rescaling is ‘NEAREST’, ‘ANTIALIAS’ or ‘INV_AVERAGE’.

class camfr.Point(x, y)

A 2D point. In a Geometry, x is the propagation direction (z of the Stack) and y the transverse one.

compare(p)
class camfr.Rectangle(p1, p2, mat)

A rectangle of Material mat between opposite corners p1 and p2 (Points), for a Geometry.

center()
compare(r)
height()
intersection_at_x(x)
width()
class camfr.Square(c, a, mat)

A square of Material mat, centre Point c, side a, for a Geometry.

compare(s)
intersection_at_x(x)
to_rectangle()
class camfr.Circle(c, r, mat)

A disc of Material mat, centre Point c, radius r, for a Geometry.

compare(c)
intersection_at_x(x)
class camfr.Triangle(p1, p2, p3, mat)

A triangle of Material mat with vertices p1, p2, p3 (Points), for a Geometry.

compare(t)
intersection_at_x(x)
class camfr.Picture(name, n_min=0, n_max=2.5, materials=[])

A bitmap image (png, jpg, …) as a structure, for a Geometry.

The image is converted to grey scale; white maps to index n_min, black to n_max, and grey levels are interpolated linearly (or taken from the list materials). A Picture is not combined with other shapes: only the last Picture added to a Geometry is used.

img_to_expression(z0, z1, dz=0, verbose=False, rescaling='ANTIALIAS')

3D

class camfr.Geometry3D(background_mat, M1, M2)

A 3D structure built from shapes, discretised into Sections.

As Geometry, one dimension up: to_expression slices along z and builds a Section (with M1, M2 as in Section) for each distinct slice.

add(s)
to_expression(x0, x1, dx, y0, y1, dy, z0, z1, dz, add_flipped=0)

Discretise into an Expression of Sections along z (steps dz); x and y as in Geometry.to_expression.

class camfr.Point3D(x, y, z)

A 3D point: x, y transverse, z the propagation direction.

class camfr.Box(p1, p2, mat)

A box of Material mat between opposite corners p1 and p2 (Point3Ds), for a Geometry3D.

center()
height()
intersection_at_z(z)
length()
width()
class camfr.Cylinder(c, r, h, mat)

A cylinder of Material mat along y: centre Point3D c, radius r (in the x-z plane), height h, for a Geometry3D.

intersection_at_z(z)