本文整理汇总了C#中Quaternion.Normalise方法的典型用法代码示例。如果您正苦于以下问题:C# Quaternion.Normalise方法的具体用法?C# Quaternion.Normalise怎么用?C# Quaternion.Normalise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quaternion
的用法示例。
在下文中一共展示了Quaternion.Normalise方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QuaternionNormaliseTest
public void QuaternionNormaliseTest()
{
var a = new Quaternion(3.0f, 4.0f, 3.0f, 1.0f);
var expectedResult = new Quaternion(0.5070925f, 0.6761234f, 0.5070925f, 0.1690308f);
a.Normalise();
Assert.True(a.Equals(expectedResult, 1e-3f));
}
示例2: QuaternionIsNormaliseTest
public void QuaternionIsNormaliseTest()
{
var a = new Quaternion(3.0f, 4.0f, 3.0f, 1.0f);
var expectedResult = true;
a.Normalise();
var r = a.IsNormalised;
Assert.Equal<bool>(expectedResult, r);
}
示例3: addQuats
private Quaternion addQuats(Quaternion q1, Quaternion q2)
{
float x = q1.x + q2.x;
float y = q1.y + q2.y;
float z = q1.z + q2.z;
float w = q1.w + q2.w;
Quaternion q = new Quaternion(w, x, y, z);
chat(q.Normalise().ToString());
return q;
}
示例4: process
// *
// Run image manipulation
// \return Pointer to image buffer which has been set in the constructor.
//
public override TextureBuffer process() {
Quaternion qion = new Quaternion();
float sum = 0f;
Vector3 q = new Vector3();
int w = (int)mBuffer.getWidth();
int h = (int)mBuffer.getHeight();
Quaternion rotation = new Quaternion(mW, mAxis);
if (mParam != null && (mParam.getWidth() < w || mParam.getHeight() < h))
return mBuffer;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
ColourValue pixel = mBuffer.getPixel(x, y);
Quaternion v = new Quaternion(0.0f, ((pixel.r * 255.0f) - 127.5f) / 127.5f, ((pixel.b * 255.0f) - 127.5f) / 127.5f, ((pixel.g * 255.0f) - 127.5f) / 127.5f);
if (mParam != null) {
pixel = mParam.getPixel(x, y);
switch (mCompensation) {
case ABNORMALS_COMPENSATION.COMPENSATION_NORMAL:
qion = new Quaternion(0.0f, (pixel.r * 255.0f) - 127.5f, (pixel.b * 255.0f) - 127.5f, (pixel.g * 255.0f) - 127.5f);
v = v * (float)(1 - mSensitivity);
v = v + qion * ((float)mSensitivity / 127.5f);
break;
case ABNORMALS_COMPENSATION.COMPENSATION_HEIGHT:
sum = ((pixel.r + pixel.g + pixel.b) / 3.0f) * 255.0f;
qion = new Quaternion(new Radian(Math.TWO_PI * sum / 765.0f * mSensitivity), new Vector3(0.0f, 1.0f, 0.0f));
rotation = rotation * qion;
break;
case ABNORMALS_COMPENSATION.COMPENSATION_QUATERNION:
q = new Vector3((pixel.r * 255.0f) - 127.5f, (pixel.b * 255.0f) - 127.5f, (pixel.g * 255.0f) - 127.5f);
qion = new Quaternion(new Radian(2.0f / 255.0f * Math.PI * pixel.a * mSensitivity), q);
rotation = rotation * qion;
break;
}
}
v = rotation * v * rotation.Inverse();
float norm = v.Normalise();
if (mMirror == ABNORMALS_MIRROR.MIRROR_X_YZ || mMirror == ABNORMALS_MIRROR.MIRROR_X_Y_Z)
mBuffer.setRed(x, y, (1.0f - v.x * 0.5f + 0.5f));
else
mBuffer.setRed(x, y, (v.x * 0.5f + 0.5f));
if (mMirror == ABNORMALS_MIRROR.MIRROR_Y_XZ || mMirror == ABNORMALS_MIRROR.MIRROR_X_Y_Z)
mBuffer.setGreen(x, y, (1.0f - v.z * 0.5f + 0.5f));
else
mBuffer.setGreen(x, y, (v.z * 0.5f + 0.5f));
mBuffer.setBlue(x, y, (v.y * 0.5f + 0.5f));
}
}
Utils.log("Modify texture with abnormals filter");
return mBuffer;
}
示例5: LookAt
public void LookAt(Vector3 vector)
{
Vector3 direction = vector - Position;
direction.Normalise();
if(direction == Vector3.ZERO) return;
var forward = direction;
forward.Normalise();
var right = direction.CrossProduct(Vector3.UNIT_Y);
right.Normalise();
var up = right.CrossProduct(forward);
up.Normalise();
var quaternion = new Quaternion(right, up, -forward);
quaternion.Normalise();
Orientation = quaternion;
}