Closed HomerReid closed 6 years ago
Change the intersect_line_with_object
function to:
/* Compute the intersections with o of a line along p+s*d in the interval s in [a,b], returning
the length of the s intersection in this interval. (Note: o must not be a compound object.) */
double intersect_line_segment_with_object(vector3 p, vector3 d, geometric_object o, double a, double b)
To be more precise, define the function χ(s) = 1 if the point p+s*d
is in the object, and χ(s) = 0 if the point p+s*d
is not in the object. What we want is ∫ₐᵇ χ(s) ds.
For the previously existing objects, intersect_line_segment_with_object
is defined by
double s[2];
if (2 == intersect_line_with_object(p, d, o, s)) {
double ds = (s[0] < s[1]
? MIN(s[1],b) - MAX(s[0],a)
: MIN(s[0],b) - MAX(s[1],a));
return (ds > 0 ? ds : 0.0);
}
else
return 0.0;
overlap_integrand
will now call:
return intersect_line_segment_with_object(p, data->dir, data->o, a0, b0) * scale_result;
instead of intersect_line_with_object
cc @DerekK88, who has been playing with GDSII import for Meep.
for technical reasons having to do with how Scheme code is compiled to use libctl, all the code needs to be in geom.c, so just paste prism.c at the end of this separated by /****************************************/
lines.
at the top of geom.c, add # define PRISM prism::
after the corresponding line for CYL
in #ifdef CXX_CTL_IO
, and add # define PRISM
in the #else
clause.
Only make_prism
should be exported — the other functions (except for make_prism
) should be declared as static
and removed from ctlgeom.h
Added a new implementation of
geometric_object
for user-defined prisms, i.e. arbitrary planar polygons (given by user-defined list of vertices) extruded a user-defined thickness in a user-defined direction. Example inutils/test-prism.c
.Sample code: