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

Add Scale() method #94

Open
Zyl9393 opened this issue Oct 15, 2023 · 1 comment
Open

Add Scale() method #94

Zyl9393 opened this issue Oct 15, 2023 · 1 comment

Comments

@Zyl9393
Copy link
Contributor

Zyl9393 commented Oct 15, 2023

I have use for a method which takes a vector and returns a new vector where every element is the product of the respective elements of the vector and the elements of the receiver vector, e.g.:

func (v1 Vec3) Scale(v2 Vec3) Vec3{
    return Vec3{v1[0] * v2[0], v1[1] * v2[1], v1[2] * v2[2]}
}

In my case I use it to scale the vertices of a 3D object with a per-axis-controllable factor, which is a common CGI feature to have to provide more artistic control over having just a single factor that gets used for each dimension.

It is trivially implementable and testable. This issue is mostly to discuss method name and whether this is wanted. I'm open to creating an MR if this is ok.

@luisgargitter
Copy link
Contributor

Does a Matrix not do the trick?

v := Diag3(scale).Mul3x1(v)

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

2 participants