go-gl / mathgl

A pure Go 3D math library.
BSD 3-Clause "New" or "Revised" License
554 stars 65 forks source link

Add LenSqr functions #74

Closed Zyl9393 closed 5 years ago

Zyl9393 commented 5 years ago

Added SqrLen() functions which return squared vector length. This can make some lines shorter when variable names are long, e.g.: worldSpaceFragmentCenter.Dot(worldSpaceFragmentCenter) vs. worldSpaceFragmentCenter.SqrLen() Understandable if not wanted, though. Mostly learning how 2 github over here. Have a nice day.

pwaller commented 5 years ago

Thanks for fixing the issues I raised!

One thing that occured to me as I go to merge it:

How about LenSquared as the name of the function? Then if you're using an editor with autocomplete, it will show up as you're looking for Len - improving the discoverability. Also it would appear next to Len in the documentation: https://godoc.org/github.com/go-gl/mathgl/mgl32

Let me know what you think. Happy to accept it as is otherwise - though I will squash the history down to just "Add ... functions", to avoid the merge commit going from master into the development branch.

MMulthaupt commented 5 years ago

I would expect autocomplete to list the function regardless of where in the name the substring is found, but regarding the documentation, you raise a good point. Maybe call it LenSqr then, or LenSq even? Having it short was one of main reasons for making this, and Sq is a well understood shortcut in anything math-related; even Java refrains from its usual verbosity, calling the square root function in its Math package sqrt.

pwaller commented 5 years ago

OK, then :+1: to LenSqr from me.

Zyl9393 commented 5 years ago

Should be good now.