gl-matrix icon indicating copy to clipboard operation
gl-matrix copied to clipboard

mat4 move

Open bahaaaldin214 opened this issue 5 years ago • 4 comments

I think a mat4 move function is necessary if you want to move a matrix to a position. I have this:

/**
* moves a mat4 to vec3
*
* @param {mat4} out the receiving matrix
* @param {vec3} v the new coordinates to move to
* @returns {mat4} moved 4x4 matrix
*/

export function moveToVec3(out, v){
 
 out[12] = v[0];
 out[13] = v[1];
 out[14] = v[2];
 
}

I'm sure others would find it useful too

bahaaaldin214 avatar Nov 17 '19 19:11 bahaaaldin214

A function to set the translation value to something is certainly useful. However, I'm not entirely convinced that it's really needed and thus worth the extra code.

You can already move a matrix using the translate function. If you want to set the translation to a certain value, you can either directly modify the values or call getTranslation and do the mathematics yourself.

stefnotch avatar Nov 17 '19 19:11 stefnotch

yeah I know about the translate function, bu that 6 LOS function saves so much time, and the trouble to go through the mathematic

bahaaaldin214 avatar Nov 17 '19 23:11 bahaaaldin214

I fully agree that setter methods like mat4.moveToVec3 would be convenient. The downside is that I'd have to add all setter methods (consistency) which in turn would increase the file size. And then unit tests for everything would have to be written.

So, I'd love to see a compelling use case or a high demand before going through all that trouble.

stefnotch avatar Nov 18 '19 07:11 stefnotch

Ah I see I underestimated the trouble, well hopefully there will be a higher demand!

Thank you for your time

bahaaaldin214 avatar Nov 18 '19 15:11 bahaaaldin214