Index: /issm/trunk-jpl/src/m/plot/plot_quiver.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/plot_quiver.js	(revision 20791)
+++ /issm/trunk-jpl/src/m/plot/plot_quiver.js	(revision 20792)
@@ -25,6 +25,7 @@
 	var is2d = meshresults[4]; 
 	var isplanet = meshresults[5];
-	var vx = md.initialization.vx; 
-	var vy = md.initialization.vy; 
+	var v = md.initialization.vel;
+	var vx = md.initialization.vx;
+	var vy = md.initialization.vy;
 		
 	//Compue scaling through matrices for 2d meshes and vertices for 3d meshes
@@ -93,38 +94,44 @@
 		vertices.itemSize = 3;
 		var xyz = vec3.create();
+		var xyz = vec3.create();
 		var direction = vec3.create();
 		var vertex = vec3.create();
+		var vertexBase = vec3.create();
+		var verticesArrow = [vec3.fromValues(0.0, 0.0, 0.0), vec3.fromValues(1.0, 0.0, 0.0), vec3.fromValues(0.667, -0.167, 0.0), vec3.fromValues(1.0, 0.0, 0.0), vec3.fromValues(0.667, 0.166, 0.0), vec3.fromValues(1.0, 0.0, 0.0)];
 		var magnitude;
 		var color = edgecolor;
 		var scaling = options.getfieldvalue('scaling',1);
+		var scale;
 		for(var i = 0; i < x.length; i++){
 			//Check for NaN values and remove from indices array as necessary, but preserve vertex array spacing
 			if (isNaN(x[i]) || isNaN(y[i]) || isNaN(z[i])) continue;
 			//Scale vertices
-			xyz1 = vec3.fromValues(x[i], y[i], z[i]);
-			magnitude = vec3.length(xyz1) + md.geometry.surface[i] * vertexscale;
-			vec3.normalize(direction, xyz1);
+			xyz = vec3.fromValues(x[i], y[i], z[i]);
+			magnitude = vec3.length(xyz) + md.geometry.surface[i] * vertexscale;
+			vec3.normalize(direction, xyz);
 			vec3.scale(vertex, direction, magnitude);
-			vertices[vertices.length] = vertex[0];
-			vertices[vertices.length] = vertex[1];
-			vertices[vertices.length] = vertex[2];
+			vec3.copy(vertexBase, vertex);
 			
-			xyz2 = vec3.fromValues(vx[i], vy[i], 0.0);
-			magnitude = 1000.0*scaling; //mesh resolution
-			vec3.normalize(direction, xyz2);
-			vec3.scale(direction, direction, magnitude);
-			vec3.add(vertex, direction, vertex);
-			vertices[vertices.length] = vertex[0];
-			vertices[vertices.length] = vertex[1];
-			vertices[vertices.length] = vertex[2];
-			
-			colors[colors.length] = color[0];
-			colors[colors.length] = color[1];
-			colors[colors.length] = color[2];
-			colors[colors.length] = color[3];
-			colors[colors.length] = color[0];
-			colors[colors.length] = color[1];
-			colors[colors.length] = color[2];
-			colors[colors.length] = color[3];
+			scale = scaling*v[i];
+			var modelMatrix = mat4.create();
+			var scaleMatrix = mat4.create();
+			var rotationMatrix = mat4.create();
+			mat4.scale(scaleMatrix, scaleMatrix, vec3.fromValues(scale, scale, scale));
+			mat4.rotate(rotationMatrix, rotationMatrix, Math.atan2(vy[i], vx[i]), [0.0, 0.0, 1.0]);
+			mat4.multiply(modelMatrix, rotationMatrix, scaleMatrix);
+
+			var temp = vec3.fromValues(0.0, 0.0, 0.0);
+			for (var j = 0; j < 6; j++){
+				vec3.transformMat4(vertex, verticesArrow[j], modelMatrix);
+				vec3.add(vertex, vertex, vertexBase);
+				vertices[vertices.length] = vertex[0];
+				vertices[vertices.length] = vertex[1];
+				vertices[vertices.length] = vertex[2];
+				
+				colors[colors.length] = color[0];
+				colors[colors.length] = color[1];
+				colors[colors.length] = color[2];
+				colors[colors.length] = color[3];
+			}
 		}
 	}
