Skip to content

The from_points for Box2D and Box3D does not work quite as advertised. #519

Closed
@kyp44

Description

@kyp44

I get that the max of the box structs are non-inclusive, and that is all fine. However, consider this code:

use euclid::default::{Box2D, Box3D, Point2D, Point3D};

fn main() {
    let p2 = Point2D::new(1, 1);
    let b2 = Box2D::from_points(vec![p2]);
    assert!(!b2.is_empty());
    assert!(b2.contains(p2));

    let p3 = Point3D::new(1, 1, 1);
    let b3 = Box3D::from_points(vec![p3]);
    assert!(!b3.is_empty());
    assert!(b3.contains(p3));
}

All of the above assertions fail, which seems to contradiction the documentation of the from_points method, according to which it "Returns the smallest box containing all of the provided points." Basically the maximum point passed in will never actually be contained in the box.

This should be a very simple fix, and I'm happy to implement it once this has been confirmed as a genuine bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions