 # Applies a transformation matrix on an array of points.
-M4x4.transformPointsAffine = (m, points, r) ->
-  
-  r = new MJS_FLOAT_ARRAY_TYPE(points.length) unless r?
+M4x4.transformPointsAffine = (m, points, r = new MJS_FLOAT_ARRAY_TYPE(points.length)) ->
 
   for i in [0...points.length] by 3
     v0 = points[i]


  r

M4x4.makeRotate2 = (axis, r) ->

  r = new MJS_FLOAT_ARRAY_TYPE(16) unless r?

  # orthogonal vector to (0,1,0) and rotation vector
  ortho = V3.normalize([axis[2], 0, -axis[0]])

  # dot product of (0,1,0) and rotation
  dotProd = axis[1]
  
  # transformation of dot product for cosA
  cosA = dotProd / V3.length(axis)
  sinA = Math.sqrt(1 - cosA * cosA)
  
  # calculate rotation matrix
  r[0] = cosA + ortho[0] * ortho[0] * (1 - cosA)
  r[1] = -ortho[2] * sinA
  r[2] = ortho[0] * ortho[2] * (1 - cosA)
  r[3] = 0
  r[4] = ortho[2] * sinA
  r[5] = cosA
  r[6] = -ortho[0] * sinA
  r[7] = 0
  r[8] = ortho[0] * ortho[2] * (1 - cosA)
  r[9] = ortho[0] * sinA
  r[10] = cosA + ortho[2] * ortho[2] * (1 - cosA)
  r[11] = 0
  r[12] = 0
  r[13] = 0

  else
    
    mat = M4x4.makeRotate2 directionVector
    
    M4x4.transformPointsAffineWithTranslation(mat, translationVector, vertices, output)

# `_.throttle2` makes a function only be executed once in a given
# time span -- no matter how often you it. We don't recomment to use 
