Skip to content
This repository has been archived by the owner on Oct 12, 2019. It is now read-only.

Matrix4x4 * AbstractVector{Vector4} #36

Closed
babaq opened this issue Dec 17, 2014 · 4 comments
Closed

Matrix4x4 * AbstractVector{Vector4} #36

babaq opened this issue Dec 17, 2014 · 4 comments

Comments

@babaq
Copy link

babaq commented Dec 17, 2014

i just found this package after i finished my own and really liked the meta-programming way to generate all the things i coded by hands.

i could find nearly all the functions i coded in this package, except that i need to translate/rotate a large array of Vector4, which is a fairly common thing in 3D graphics.

for example:

mymodel = fill(Vector4(1.0),20)
tm = Matrix4x4([1.0 0.0 0.0  2.0;
                0.0 1.0 0.0  0.0;
                0.0 0.0 1.0  0.0;
                0.0 0.0 0.0  1.0])
transformedmodel = tm*mymodel

i know for small array of Vector4, i could do map(x->tm*x,mymodel). but would be faster if convert the array of Vector4 to a matrix and multiply.

any consideration to add this functionality?

@twadleigh
Copy link
Contributor

Hmm. I'd be happy to entertain a pull request, but I'm not sure this really belongs in the library. You can accomplish this with an explicit loop or comprehension (or map, as you note), in which case it seems superfluous to add to the library (which is mostly about code generation), or you can convert it to generic matrix multiplication, in which case it wouldn't really belong in this library, either.

@babaq
Copy link
Author

babaq commented Dec 17, 2014

Your argument makes a lot of sense. the proposed functionality actually means to transform or multiply each of Vector4 in an array with a Matrix4x4. Adding to * function may pollute the meaning of matrix multiplication, but it does fit into .* which is simpler than the equivalent for loop or map. I was just thinking from a user perspective hoping those things automagically work:)

one can always convert Vector{Vector4} to generic matrix, that make me thinking is it right to support operation between ImmutableArrays and Arrays

tm=Matrix4x4(1.0)
a=Vector4(2.0)
tm*a # result in Vector4
[tm]*[a] # result in 4-element Vector
tm*[a] # doesn't work
[tm]*a # doesn't work

i am skeptical of any complication of support this, maybe any operation between ImmutableArrays and generic Arrays should return generic Arrays.

@twadleigh
Copy link
Contributor

The "it should just work" argument does make sense. And, yes, I'd agree that any mixing of ImmutableArray and other arrays should make vanilla arrays.

Could you spec out some definitions for the additional functionality you'd like to see in a PR or gist?

Also, just a heads-up, but it's been a looong time since I've had my head in this code, so it might take me a while to spin up on thinking about the best way to integrate it.

Thanks for making the effort to contribute.

@babaq
Copy link
Author

babaq commented Dec 17, 2014

Sure, i'll try to make it happen:)

@babaq babaq closed this as completed Dec 17, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants