Conversation
- Invert formula was wrong - Multiplication re-ordered terms (quaternion multiplication is not commutative) - addWith subtracted Also added more tests.
Fixes for DualQuaternion
|
Still WIP no additional testing yet added. |
|
Stuff requested I action:
|
|
Getting a strange edge case which I have omitted for now. |
|
@tbrosman Are these tests suitable or does it need more coverage? I am not yet sure how to deal with the one odd failure, I expect styling needs improvement I can move it back into Test3D and tidy styling if you feel the tests are suitable, and take another look at the edge case. |
|
Had quite a few problems with pushing to specific branches, but my current changes should all be there. |
|
I was going to ask do you use a plugin or something to apply styles, do you use the 'recommended' haxe styling, I think that has a plugin or similar but not tried it yet. |
| #if (sys && !EXIT_ON_FINISH) | ||
| Sys.stdin().readLine(); | ||
| #else | ||
| #elseif !js |
There was a problem hiding this comment.
Should be #elseif sys. I missed that case when I wrote the test driver.
| * @param t The Vector4 ( translation ) | ||
| * @return The DualQuaternion | ||
| */ | ||
| public static inline function fromAxisAngle( angleDegrees:Float |
There was a problem hiding this comment.
Minor: should match existing function style (in this case just put it all on the same line)
Spacing below should also match existing.
| */ | ||
| public static inline function fromAxisAngle( angleDegrees:Float | ||
| , axis: Vector3 | ||
| , vec4: Vector4 ):DualQuaternion |
There was a problem hiding this comment.
Probably should be "t" or "translation" or something (also update documentation to match).
| { | ||
| var cosHalfAngle = Math.cos(theta / 2.0); | ||
| var sinHalfAngle = Math.sin(theta / 2.0); | ||
| var real = new Quaternion(cosHalfAngle,sinHalfAngle * axis.x,sinHalfAngle * axis.y, |
There was a problem hiding this comment.
This should live in Quaternion. Then you can call Quaternion.fromAxisRadian.
| * @param a | ||
| * @return ~a | ||
| */ | ||
| @:op(~A) |
There was a problem hiding this comment.
Like I said in my previous comment, this might not make the most sense for choice of conjugate. Here's my reasoning:
- Rotation by a unit length quaternion q is calculated as q * v * (~q) (where ~q is the complex conjugate).
- With this convention, transformation by a dual quaternion q would be written q * v * (~q.dualConjugate()) which is kind of gross (also, dualConjugate doesn't exist yet, so you can't actually write this).
| public inline function applyScale(s:Float):DualQuaternion | ||
| { | ||
| var cloned = clone(); | ||
| cloned = cloned*DualQuaternion.scalar( s ); |
There was a problem hiding this comment.
Why not just call scaleMultiply? Unless scalar() is inlined, this will create an intermediate DualQuaternion.
|
|
||
| private inline function get_normal():DualQuaternion | ||
| { | ||
| var mag = dot(this, this); |
There was a problem hiding this comment.
This isn't actually the magnitude, but the magnitude squared. Just call .length.
| private inline function get_normal():DualQuaternion | ||
| { | ||
| var mag = dot(this, this); | ||
| if( mag < 0 ) return null; |
There was a problem hiding this comment.
This condition is impossible to hit. Dot products are always >= 0 by definition (if it isn't, it's not a dot product). I think you want to check for when mag == 0. In that particular case you should just return the existing dual quaternion (it is the zero dual quaternion).
| public inline function normalize(): DualQuaternion | ||
| { | ||
| var mag = dot( this, this ); | ||
| if( mag < 0 ) return null; |
There was a problem hiding this comment.
Duplicates code with get_normal. Suggestion: call .clone().normalize() in get_normal. I actually don't do this correctly in my Quaternion code, so normal does fail on 0-length quaternions (oops).
| */ | ||
| public inline function rotate(u:Vector3):Vector3 | ||
| { | ||
| normalize(); |
There was a problem hiding this comment.
Quaternion doesn't implicitly normalize on rotate, so neither should DualQuaternion. It is up to the caller to make the trade-off between precision and speed.
| * @param b The other quaternion. | ||
| * @return The arccosine angle between this vector and the other in radians. | ||
| */ | ||
| public inline function angleWith(b:Quaternion):Float |
There was a problem hiding this comment.
This seems unnecessary. There's an angleWith on Quaternion, so the caller can just call dualQuaternion.real.angleWith(quaternion).
| * | ||
| * @return The modified object. | ||
| */ | ||
| public inline function applyDualConjugate():DualQuaternion |
There was a problem hiding this comment.
Reminder: needs to be implemented.
| // yaw (Z), pitch (Y), roll (X) | ||
| @:forward | ||
| abstract Euler( Vector3 ) from Vector3 to Vector3 { | ||
| public inline function new( roll: Float, pitch: Float, yaw: Float ){ |
There was a problem hiding this comment.
Minor: order fields like existing structures (properties on top, make setter/getter implementations private and put them on the bottom).
| import hxmath.math.Matrix4x4; | ||
| import hxmath.math.Vector2; | ||
|
|
||
| #if !js |
| @@ -0,0 +1,36 @@ | |||
| -cmd echo 'js test' | |||
There was a problem hiding this comment.
Is it not possible to reference hxml here? I admit I've never run this on a Mac. What's the difference? I see a lot of cd'ing into directories that doesn't happen on the "regular" hxml targets. Is it something to do with the path convention for running binaries/scripts?
|
Looking much better. I left a few more comments, mostly cleanup stuff (and the conjugate operator needs some work). I'm not using haxecheckstyle or anything (I really should). One day I'll learn how to configure it to look the way I want it to. |
Just current Dual Quaternion changes