| 04-02-2007, 10:13 PM | #1 |
i have 2 vectors, 1 normal n vector and 1 other vector v. Both are in 3d space. Wat would you guys suggest to do if i want to mirror vector v over vector n: \| will be |/ And with only vector math please, no cos or sin. Possible matrix is fine, but i dont know matrix so i need an exact formula like the vector product thingy. I ask this because i wanna find projection vector without using slow functions like sin and cos |
| 04-02-2007, 11:03 PM | #2 |
JASS:method project takes vector P returns vector local real l = this.x*P.x+this.y*P.y+this.z*P.z local vector R if (l==0.) then return 0 endif set l = SquareRoot(P.x*P.x+P.y*P.y+P.z*P.z / l) set R = vector.create() set R.x = P.x * l set R.y = P.y * l set R.z = P.z * l return R endmethod |
| 04-02-2007, 11:34 PM | #3 |
i need a math forumla not code, i dont read this new code syntax tat well :P and wat is l, and where is normal vector |
| 04-03-2007, 02:52 AM | #4 |
we can see graphically or trigometrically that you are expressing the following relations: 1) n x v = v' x n 2) n . v = v' . n crossing both sides of 1) with n, we find 3) n x (n x v) = n x (v' x n) 4) (n . v) n - (n . n) v = (n . n) v' - (n . v') n plugging in 2) for the last term in 4) we find 5) (n . v) n - (n . n) v = (n . n) v' - (n . v) n combining terms and solving for v': 6) v' = (2(n.v)/(n.n)) n - v aka 2 (v proj n) - v grim showed you how to do (v proj n), assuming that graphically the extension to v' was obvious. which really it should be, this is only a difficult problem if you try to do it algebraically instead of just staring at the picture. |
| 04-04-2007, 01:31 AM | #5 |
hm thnx, but Infranse showed me a way already, since i ahve problems with wc3c so couldnt access |
