Skip to content
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

Scale mod, div by scalar #499

Closed
ArtHome12 opened this issue Mar 7, 2023 · 3 comments
Closed

Scale mod, div by scalar #499

ArtHome12 opened this issue Mar 7, 2023 · 3 comments

Comments

@ArtHome12
Copy link
Contributor

Is Scale's lack of the ability to multiply and divide by T due to something or is it just unfinished? I have to write code like this

let step: f32...
let scale = self.scale.get() * step;
let scale = scale.clamp(self.min_scale.get(), self.max_scale.get());
Scale::new(scale)

Instead this

let scale = self.scale * step;
scale.clamp(self.min_scale, self.max_scale)
@ArtHome12
Copy link
Contributor Author

Although clamp() won't work:

the following trait bounds were not satisfied:
f32: Ord

@ArtHome12
Copy link
Contributor Author

ArtHome12 commented Mar 22, 2023

I came to the conclusion that the step from the example in the post should not be T, but already Scale<T...>
And no mod, div by scalar` is required.

Perhaps for completeness, need to add Scale::transform_length() (in addition to transform_vector, transform_point, transform_size...), but guided by the rule "less code is better" I think it should not do this. At least until someone needs it.

Scale::clamp() will made according to the same in crate::point

@ArtHome12
Copy link
Contributor Author

Done 77e6901

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant