{"action":"created","issue":{"url":"https://api.github.com/repos/chandlerprall/Physijs/issues/41","labels_url":"https://api.github.com/repos/chandlerprall/Physijs/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/chandlerprall/Physijs/issues/41/comments","events_url":"https://api.github.com/repos/chandlerprall/Physijs/issues/41/events","html_url":"https://github.com/chandlerprall/Physijs/issues/41","id":6600273,"number":41,"title":"Setting relative angular velocity","user":{"login":"DungFu","id":443370,"avatar_url":"https://avatars.githubusercontent.com/u/443370?v=3","gravatar_id":"","url":"https://api.github.com/users/DungFu","html_url":"https://github.com/DungFu","followers_url":"https://api.github.com/users/DungFu/followers","following_url":"https://api.github.com/users/DungFu/following{/other_user}","gists_url":"https://api.github.com/users/DungFu/gists{/gist_id}","starred_url":"https://api.github.com/users/DungFu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DungFu/subscriptions","organizations_url":"https://api.github.com/users/DungFu/orgs","repos_url":"https://api.github.com/users/DungFu/repos","events_url":"https://api.github.com/users/DungFu/events{/privacy}","received_events_url":"https://api.github.com/users/DungFu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chandlerprall/Physijs/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2012-09-02T03:59:34Z","updated_at":"2015-03-24T13:36:07Z","closed_at":"2012-09-08T10:41:11Z","body":"I can't seem to get setting angular velocity relative to current position and rotation to work. Below is some of the code that I have: \n\n```javascript\nvar zeroV = new THREE.Vector3(0,0,0);\nvar camVector = zeroV;\n\nfunction projCalc(thetax, thetay, thetaz, cx, cy, cz, dx, dy, dz) {\n\tvar M1 = $M([\n\t\t[1, 0, 0],\n\t\t[0, Math.cos(thetax), -1*Math.sin(thetax)],\n\t\t[0, Math.sin(thetax), Math.cos(thetax)]\n\t]);\n\tvar M2 = $M([\n\t\t[Math.cos(thetay), 0, Math.sin(thetay)],\n\t\t[0, 1, 0],\n\t\t[-1*Math.sin(thetay), 0, Math.cos(thetay)]\n\t]);\n\tvar M3 = $M([\n\t\t[Math.cos(thetaz), -1*Math.sin(thetaz), 0],\n\t\t[Math.sin(thetaz), Math.cos(thetaz), 0],\n\t\t[0, 0, 1]\n\t]);\n\tvar C = $M([\n\t\t[cx],\n\t\t[cy],\n\t\t[cz]\n\t]);\n\tvar D = $M([\n\t\t[dx],\n\t\t[dy],\n\t\t[dz]\n\t])\n\n\tvar M123 = M1.x(M2).x(M3);\n\tvar M123inv = M123.inv();\n\tvar result1 = M123.x(C).add(D);\n\tvar result2 = M123inv.x(result1);\n\treturn result2;\n}\n\nvar otherEnd = projCalc(rotx, roty, rotz, camx, camy, camz, -1, 0, 0);\nvar unitVX = (otherEnd.elements[0][0] - camx);\nvar unitVY = (otherEnd.elements[1][0] - camy);\nvar unitVZ = (otherEnd.elements[2][0] - camz);\ncamVector.x = unitVX;\ncamVector.y = unitVY;\ncamVector.z = unitVZ;\n\ncamera.physics.setAngularVelocity(camVector);\n```\n\ncamx, y, z is the position of the object that is going to be given the angular velocity\n\nrotx, y, z is the current rotation of the object that is going to be given the angular velocity\n\nand -1, 0, 0 is the relative axis of rotation\n\nall projCalc() does is give the point that is (-1,0,0) in the relative space in the global coordinate plane (I used Sylvester to do the matrix math)\n\nBut whenever I try to set the angular velocity, it only works properly when the rotation is around 0 otherwise it is horribly wrong.\n\nIf there is an easier way to do this, that would be helpful! As a side note, it would be awesome if there could be a relative setAngularVelocity and getAngularVelocity in Physijs so that velocities could be changed relative to an objects current rotation.\n\nThanks\n\nP.S. These are just code snippets above. My init and animate functions work just fine so that is not one of my issues."},"comment":{"url":"https://api.github.com/repos/chandlerprall/Physijs/issues/comments/85499287","html_url":"https://github.com/chandlerprall/Physijs/issues/41#issuecomment-85499287","issue_url":"https://api.github.com/repos/chandlerprall/Physijs/issues/41","id":85499287,"user":{"login":"kellycode","id":6690553,"avatar_url":"https://avatars.githubusercontent.com/u/6690553?v=3","gravatar_id":"","url":"https://api.github.com/users/kellycode","html_url":"https://github.com/kellycode","followers_url":"https://api.github.com/users/kellycode/followers","following_url":"https://api.github.com/users/kellycode/following{/other_user}","gists_url":"https://api.github.com/users/kellycode/gists{/gist_id}","starred_url":"https://api.github.com/users/kellycode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kellycode/subscriptions","organizations_url":"https://api.github.com/users/kellycode/orgs","repos_url":"https://api.github.com/users/kellycode/repos","events_url":"https://api.github.com/users/kellycode/events{/privacy}","received_events_url":"https://api.github.com/users/kellycode/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T13:36:07Z","updated_at":"2015-03-24T13:36:07Z","body":"Maybe this one, but it seems broken atm: http://www.chandlerprall.com/labs/Physijs/examples/relative_velocity.html"}}