     plane_from_norm_point out2, v1, p
     return
 
+tmp4a = vec4.create()
+tmp4b = vec4.create()
+intersect_vector_plane = (out, origin, vector, plane) ->
+    # out is vec3
+    # origin is vec3
+    # vector is vec3 NORMALIZED
+    # plane is vec4
+    rect_from_dir_point tmp4a, tmp4b, vector, origin
+    planes_intersection out, tmp4a, tmp4b, plane
+
 v_dist_point_to_rect = (out, p, rp, dir)->
     # p is a point
     # rp is a point of the rect

    vec3.cross out, vec3.sub(v2,p,rp), vec3.normalize v1, dir
    return out

module.exports = {
    planes_intersection, plane_from_norm_point,
    rect_from_dir_point, v_dist_point_to_rect
}


rect_from_dir_point = (out1, out2, d, p)-> # UNTESTED
    # p is a point of the rect
    # d is the director vector of the rect, NORMALIZED
    # the result will be 2 planes which define the rect, in a
    # 4x2 row-major matrix (or first half of 4x4)
    vec3.set v1, 1,0,0
