-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extrusion bounded #13346
Extrusion bounded #13346
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the code is good, although I haven't looked through the ellipse code and the tests yet.
Co-Authored-By: IQuick 143 <IQuick143cz@gmail.com>
let y = signum.y * b * b / (b * b + m * m * a * a).sqrt(); | ||
let x = signum.x * a * (1. - y * y / b / b).sqrt(); | ||
rotation * Vec3::new(x, y, 0.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible division by zero if ellipse is degenerate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool! Everything looks as I would expect. Finding the Ellipse code a little hard to follow without comments, but think I get the gist.
Haven't visually inspected yet, will try to later. Approving.
} | ||
} | ||
|
||
fn bounding_sphere<T: Primitive2d + Bounded2d>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should probably be renamed to something more descriptive which doesn't share a name with the Bounded3d
method. Maybe bounding_sphere_from_base
or similar?
fn aabb_3d(&self, translation: Vec3, rotation: Quat) -> Aabb3d { | ||
let Vec2 { x: a, y: b } = self.base_shape.half_size; | ||
let normal = rotation * Vec3::Z; | ||
let conjugate_rot = rotation.conjugate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a little more readable:
let conjugate_rot = rotation.conjugate(); | |
let inverse_rot = rotation.conjugate(); |
Objective
Bounded3d
for someExtrusion<T>
Aabb3d
s andBoundingSphere
s for any extrusion with aBounded2d
base shapeSolution
Bounded3d
for all 2Dbevy_math
primitives with the exception ofPlane2d
. As far as I can see,Plane2d
is pretty much a line? and I think it is very unintuitive to extrude a plane and get a plane as a result.extrusion_bounding_box
andextrusion_bounding_sphere
. These are not always used internally since there are faster methods for specific extrusions. Both of them produce the optimal result within precision limits though.Testing