Skip to content

Loading…

AABB from_points does not work as expected #23

Closed
mbj2011 opened this Issue · 4 comments

2 participants

@mbj2011

The initial min/max vectors might not be part of the minimal AABB containing the provided points.

@Dav1dde
Owner

I am not sure if I understand what you mean, can you provide me an example?

@mbj2011

Absolutely.

AABB aabb = AABB.from_points([vec3(1, 1, 1), vec3(2, 2, 2)]);

results in aabb.center() having the value [1, 1, 1], where it should have been [1.5, 1.5, 1.5].

I temporarily fixed it using the following code instead:

static AABBT from_points(vec3[] points) {
    AABBT res;

    res.min = res.max = points[0];

    foreach(v; points[1 .. $]) {
        res.expand(v);
    }

    return res;
}
@Dav1dde Dav1dde added a commit that referenced this issue
@Dav1dde Fix issue #23 b6391e3
@Dav1dde
Owner

Thank you very much, I hopefully fixed it. Since I don't have access to a compiler right now, it would be great if you could report back!

@mbj2011

It compiles and works like it's supposed to :-)

@mbj2011 mbj2011 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.