Summary
Add an apfp::geometry::isize module to provide geometric predicates for isize coordinates.
Motivation
When integrating apfp into rgeometry, we found that isize is a commonly used coordinate type but there's no corresponding apfp::geometry::isize module. Currently we work around this by casting to i64:
impl PolygonScalar for isize {
fn cmp_slope(p: &[Self; 2], q: &[Self; 2], r: &[Self; 2]) -> std::cmp::Ordering {
use apfp::geometry::{Orientation, i64 as apfp_mod};
let orient = apfp_mod::orient2d(
&apfp_mod::Coord::new(p[0] as i64, p[1] as i64),
&apfp_mod::Coord::new(q[0] as i64, q[1] as i64),
&apfp_mod::Coord::new(r[0] as i64, r[1] as i64),
);
// ...
}
// ... similar for cmp_dist, cmp_vector_slope, cmp_perp_vector_slope, incircle
}
This works (since isize is at most 64-bit on all platforms), but it would be cleaner to have native isize support.
Proposed Solution
Add apfp::geometry::isize module with the same API as the other integer modules:
Coord struct with isize components
orient2d, orient2d_vec, orient2d_normal
cmp_dist
incircle
The implementation could either:
- Delegate to
i64 internally (simple, works everywhere)
- Use
cfg attributes to delegate to i32 or i64 based on platform pointer width (slightly more efficient on 32-bit platforms)
Option 1 is probably fine since 32-bit platforms are increasingly rare.
Summary
Add an
apfp::geometry::isizemodule to provide geometric predicates forisizecoordinates.Motivation
When integrating
apfpintorgeometry, we found thatisizeis a commonly used coordinate type but there's no correspondingapfp::geometry::isizemodule. Currently we work around this by casting toi64:This works (since
isizeis at most 64-bit on all platforms), but it would be cleaner to have nativeisizesupport.Proposed Solution
Add
apfp::geometry::isizemodule with the same API as the other integer modules:Coordstruct withisizecomponentsorient2d,orient2d_vec,orient2d_normalcmp_distincircleThe implementation could either:
i64internally (simple, works everywhere)cfgattributes to delegate toi32ori64based on platform pointer width (slightly more efficient on 32-bit platforms)Option 1 is probably fine since 32-bit platforms are increasingly rare.