chiark / gitweb /
shapelib: Rename nominal arg to rect from centre
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 May 2022 12:37:28 +0000 (13:37 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 11 May 2022 22:18:07 +0000 (23:18 +0100)
This is the nominal location, around which the rectangle is
centred.  This makes it clearer exp. for the call sites elsewhere,
where this parameter is just the piece position.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/shapelib.rs

index c6f8f0f185ed43af9eac4b26a0bfff812d07a599..934a05a8cbe67e6291eb12d0ae4dd5b655f2d7b8 100644 (file)
@@ -647,14 +647,14 @@ pub struct RectShape { pub xy: PosC<f64> }
 impl RectShape {
   // Used by code elsewhere eg deck.rs for occultation boundaries etc.
   #[throws(CoordinateOverflow)]
-  pub fn rect(&self, centre: Pos) -> RectC<Coord> {
+  pub fn rect(&self, nominal: Pos) -> RectC<Coord> {
     let offset = (self.xy * 0.5)?;
     let offset = offset.try_map(
       |c| c.floor().to_i32().ok_or(CoordinateOverflow)
     )?;
     let rect = RectC{ corners:
       [-1,1].iter().map(|&signum| Ok::<_,CoordinateOverflow>({
-        (centre + (offset * signum)?)?
+        (nominal + (offset * signum)?)?
       }))
         .collect::<Result<ArrayVec<_,2>,_>>()?
         .into_inner().unwrap()
@@ -663,8 +663,8 @@ impl RectShape {
   }
 
   #[throws(CoordinateOverflow)]
-  pub fn region(&self, centre: Pos) -> Region {
-    Region::Rect(self.rect(centre)?)
+  pub fn region(&self, nominal: Pos) -> Region {
+    Region::Rect(self.rect(nominal)?)
   }
 }