add support for prisms (new type of geometric_object) to libctlgeom#13
add support for prisms (new type of geometric_object) to libctlgeom#13stevengj merged 13 commits intoNanoComp:masterfrom
Conversation
… test to test-prism.c
utils/prism.c
Outdated
| /***************************************************************/ | ||
| /***************************************************************/ | ||
| GEOMETRIC_OBJECT make_prism(MATERIAL_TYPE material, | ||
| vector3 *vertices, int num_vertices, |
There was a problem hiding this comment.
This should be a const vector3 * since a copy is made of this vertex data.
utils/prism.c
Outdated
| /* if **sarray is non-null, on return it points to a newly */ | ||
| /* allocated array of length equal to the return value. */ | ||
| /***************************************************************/ | ||
| int intersect_line_with_prism(prism *prsm, vector3 p, vector3 d, double **sarray) |
There was a problem hiding this comment.
This is an inner-loop function for subpixel integration, so it shouldn't do any allocations via realloc or whatever.
Remember that subpixel averaging only needs to work in the limit where the pixels are very small compared to the object. So we shouldn't ever need to compute all of the intersections — maybe just the first and last intersection, should suffice, or knowing that it doesn't intersect at all.
|
Change the /* 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 |
|
For the previously existing objects, 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; |
|
return intersect_line_segment_with_object(p, data->dir, data->o, a0, b0) * scale_result;instead of |
|
cc @DerekK88, who has been playing with GDSII import for Meep. |
…ng unit test utils/test-prism.c
…ng unit test utils/test-prism.c
|
|
Only |
Added a new implementation of
geometric_objectfor 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 in
utils/test-prism.c.Sample code: