 Home
 » Viewing Profile: Posts: Michael Wojcik
Michael Wojcik
Member Since 28 Aug 2007Offline Last Active Feb 19 2014 01:23 PM
Community Stats
 Group Members
 Active Posts 32
 Profile Views 3,734
 Submitted Links 0
 Member Title Member
 Age 26 years old
 Birthday July 11, 1989

Gender
Male

Location
California
Contact Information
 MSN haven6of6@hotmail.com
 Website URL http://www.voidseer.com
 Skype haven6of6@hotmail.com
163
Learning
User Tools
Latest Visitors
Posts I've Made
In Topic: Lua: A return keyword followed by a table
23 August 2012  05:13 PM
Perfect explanation! Fast reply! Thanks!!
In Topic: Vector rotation via Quaternion
10 July 2012  08:19 PM
True! Lol, Thanks for pointing that out, I should have noticed that normalization was not critical to the rotation calculation. Thanks for all your help!
In Topic: Vector rotation via Quaternion
10 July 2012  05:09 PM
To the method to rotate the vector by a quaternion.
The result is always normal, no matter the magnitude of the input vector. Is this correct in the context of vector rotation via a quaternion? I was expecting the vector to be returned as a coordinate. I could ofcourse, could mutiply the result normal by the magnitude of the input vector. But I want to be sure if by definition, q * p * q1 returns a rotated normal, or coordinate.
/** * Multiplys a quaternion q with a vector v to apply the qrotation to v */ public Vector3 Rotate (Vector3 vec) { vecnormal.Set(vec); vecnormal.Normalize(); qVec.x = vecnormal.X; qVec.y = vecnormal.Y; qVec.z = vecnormal.Z; qVec.w = 0.0f; qConjugate.Set(this).Conjugate(); Quaternion qRes = qVec.Multiply(qConjugate); qTmpThis.Set(this); qRes = qTmpThis.Multiply(qRes); vec.X = qRes.x; vec.Y = qRes.y; vec.Z = qRes.z; return vec; }
The result is always normal, no matter the magnitude of the input vector. Is this correct in the context of vector rotation via a quaternion? I was expecting the vector to be returned as a coordinate. I could ofcourse, could mutiply the result normal by the magnitude of the input vector. But I want to be sure if by definition, q * p * q1 returns a rotated normal, or coordinate.
In Topic: Vector rotation via Quaternion
10 July 2012  03:57 PM
Cool! Thats was indeed the issue! You saved me alot of time, thanks! I have another question regarding the result of quaternion  vector rotation. I noticed that If I were to pass <5.0, 0.0,0.0> I get a normal (0.707107,0.707107,0) as If I passed in <1.0, 0.0,0.0>.
Does quaternion rotation with vector only work with vector normals? Or might I have messed something else up in my class?
Does quaternion rotation with vector only work with vector normals? Or might I have messed something else up in my class?
In Topic: Vector rotation via Quaternion
10 July 2012  11:23 AM
Quaternion q = new Quaternion(0.0f, 0.0f, 45f);
Initializes the quaternion in euler angles which calls this method
public void FromEulerAngles(float x, float y, float z) { float roll = MathHelper.DegreesToRadians(z); float pitch = MathHelper.DegreesToRadians(x); float yaw = MathHelper.DegreesToRadians(y); float cyaw, cpitch, croll, syaw, spitch, sroll; float cyawcpitch, syawspitch, cyawspitch, syawcpitch; cyaw = MathHelper.Cos(0.5f * yaw); cpitch = MathHelper.Cos(0.5f * pitch); croll = MathHelper.Cos(0.5f * roll); syaw = MathHelper.Sin(0.5f * yaw); spitch = MathHelper.Sin(0.5f * pitch); sroll = MathHelper.Sin(0.5f * roll); cyawcpitch = cyaw*cpitch; syawspitch = syaw*spitch; cyawspitch = cyaw*spitch; syawcpitch = syaw*cpitch; this.w = cyawcpitch * croll + syawspitch * sroll; this.x = cyawspitch * croll + syawcpitch * sroll; this.y = syawcpitch * croll  cyawspitch * sroll; this.z = cyawcpitch * sroll  syawspitch * croll; }
The Quaternion.Set sets to the calling quaternion's members, the x,y,z,w from that of the quaternion passed into set.
Here's Quaternion.Set
public Quaternion Set(Quaternion rhs) { this.x = rhs.x; this.y = rhs.y; this.z = rhs.z; this.w = rhs.w; return this; }
Heres my Quaternion.Multiply, just in case
public Quaternion Multiply(Quaternion qLocal) { w = ((w * qLocal.w)  (x * qLocal.x)  (y * qLocal.y)  (z * qLocal.z)); x = ((w * qLocal.x) + (x * qLocal.w) + (y * qLocal.z)  (z * qLocal.y)); y = ((w * qLocal.y) + (y * qLocal.w) + (z * qLocal.x)  (x * qLocal.z)); z = ((w * qLocal.z) + (z * qLocal.w) + (x * qLocal.y)  (y * qLocal.x)); normalRegenerationCount++; return this; }