本文整理汇总了C#中Vector4D类的典型用法代码示例。如果您正苦于以下问题:C# Vector4D类的具体用法?C# Vector4D怎么用?C# Vector4D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector4D类属于命名空间,在下文中一共展示了Vector4D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decompose
public static bool Decompose(Matrix4x4 m, out Vector3D scale, out Vector4D rotationQuaternion, out Vector3D translation)
{
SlimDX.Vector3 s;
SlimDX.Quaternion r;
SlimDX.Vector3 t;
if (Matrix4x4ToSlimDXMatrix(m).Decompose(out s, out r, out t))
{
scale.x = s.X;
scale.y = s.Y;
scale.z = s.Z;
rotationQuaternion.x = r.X;
rotationQuaternion.y = r.Y;
rotationQuaternion.z = r.Z;
rotationQuaternion.w = r.W;
translation.x = t.X;
translation.y = t.Y;
translation.z = t.Z;
return true;
}
else
{
scale = new Vector3D(0);
rotationQuaternion = new Vector4D(0);
translation = new Vector3D(0);
return false;
}
}
示例2: Write
public void Write(Vector4D value)
{
Write(value.X);
Write(value.Y);
Write(value.Z);
Write(value.W);
}
示例3: MouseMove
public override void MouseMove(Vector2D mouseMovePos, EnumMouseButton button)
{
base.MouseMove(mouseMovePos, button);
if (handleIndex == null) return;
Vector2D p = mouseCurrPos - new Vector2D(projectedCenter.x, projectedCenter.y);
p.x += 100;
p.y += 100;
switch (button)
{
case EnumMouseButton.Middle: movingBall.Drag(p); break;
case EnumMouseButton.Left: movingBall.Drag(p / this.ScaleRatio); break;
case EnumMouseButton.Right: movingBall.Drag(p); break;
}
Matrix4D tran = TransformController.Instance.TransformInverse * movingBall.CreateMatrix().Transpose() * TransformController.Instance.ModelMatrix;
for (int i = 0; i < handleIndex.Count; i++)
{
int j = handleIndex[i];
Vector4D q = new Vector4D((Vector3D)oldHandlePos[i], 1);
q = tran * (q - handleCenter) + handleCenter;
mesh.Vertices[j].Traits.Position.x = q.x;
mesh.Vertices[j].Traits.Position.y = q.y;
mesh.Vertices[j].Traits.Position.z = q.z;
}
//TriMeshUtil.SetUpNormalVertex(mesh);
OnChanged(EventArgs.Empty);
}
示例4: AdditionOperator
public void AdditionOperator()
{
Vector4D a = new Vector4D(1.0, 2.0, 3.0, 4.0);
Vector4D b = new Vector4D(2.0, 3.0, 4.0, 5.0);
Vector4D c = a + b;
Assert.AreEqual(new Vector4D(3.0, 5.0, 7.0, 9.0), c);
}
示例5: Normalize
public void Normalize()
{
Vector4D v, n1, n2;
double magnitude;
v = new Vector4D(3.0, 4.0, 0.0, 0.0);
n1 = v.Normalize();
n2 = v.Normalize(out magnitude);
Assert.AreEqual(1.0, n1.Magnitude, 1e-14);
Assert.AreEqual(1.0, n2.Magnitude, 1e-14);
Assert.AreEqual(5.0, magnitude, 1e-14);
v = new Vector4D(3.0, 0.0, 4.0, 0.0);
n1 = v.Normalize();
n2 = v.Normalize(out magnitude);
Assert.AreEqual(1.0, n1.Magnitude, 1e-14);
Assert.AreEqual(1.0, n2.Magnitude, 1e-14);
Assert.AreEqual(5.0, magnitude, 1e-14);
v = new Vector4D(0.0, 3.0, 4.0, 0.0);
n1 = v.Normalize();
n2 = v.Normalize(out magnitude);
Assert.AreEqual(1.0, n1.Magnitude, 1e-14);
Assert.AreEqual(1.0, n2.Magnitude, 1e-14);
Assert.AreEqual(5.0, magnitude, 1e-14);
v = new Vector4D(0.0, 0.0, 3.0, 4.0);
n1 = v.Normalize();
n2 = v.Normalize(out magnitude);
Assert.AreEqual(1.0, n1.Magnitude, 1e-14);
Assert.AreEqual(1.0, n2.Magnitude, 1e-14);
Assert.AreEqual(5.0, magnitude, 1e-14);
}
示例6: Addition
public void Addition()
{
Vector4D a = new Vector4D(1.0, 2.0, 3.0, 4.0);
Vector4D b = new Vector4D(2.0, 3.0, 4.0, 5.0);
Vector4D c = Vector4D.Add(a, b);
Assert.AreEqual(new Vector4D(3.0, 5.0, 7.0, 9.0), c);
}
示例7: Construct2
public void Construct2()
{
Vector4D v = new Vector4D(new Vector2D(1.0, 2.0), 3.0, 4.0);
Assert.AreEqual(1.0, v.X);
Assert.AreEqual(2.0, v.Y);
Assert.AreEqual(3.0, v.Z);
Assert.AreEqual(4.0, v.W);
}
示例8: Drag
public void Drag(Vector2D pt)
{
endPt = pt;
endVec = MapToSphere(pt);
double epsilon = 1.0e-5;
Vector3D prep = startVec.Cross(endVec);
if (prep.Length() > epsilon)
quat = new Vector4D(prep, startVec.Dot(endVec));
else
quat = new Vector4D();
}
示例9: MakeRotate
//from openFrameworks
private Vector4D MakeRotate(Vector3D from, Vector3D to)
{
Vector4D quat = new Vector4D();
Vector3D sourceVector = from / from.Length;
Vector3D targetVector = to / to.Length;
// Now let's get into the real stuff
// Use "dot product plus one" as test as it can be re-used later on
double dotProdPlus1 = 1.0 + sourceVector.dot(targetVector);
// Check for degenerate case of full u-turn. Use epsilon for detection
if (dotProdPlus1 < 1e-7) {
// Get an orthogonal vector of the given vector
// in a plane with maximum vector coordinates.
// Then use it as quaternion axis with pi angle
// Trick is to realize one value at least is >0.6 for a normalized vector.
if (fabs(sourceVector.x) < 0.6) {
const double norm = sqrt(1.0 - sourceVector.x * sourceVector.x);
_v.x = 0.0;
_v.y = sourceVector.z / norm;
_v.z = -sourceVector.y / norm;
_v.w = 0.0;
} else if (fabs(sourceVector.y) < 0.6) {
const double norm = sqrt(1.0 - sourceVector.y * sourceVector.y);
_v.x = -sourceVector.z / norm;
_v.y = 0.0;
_v.z = sourceVector.x / norm;
_v.w = 0.0;
} else {
const double norm = sqrt(1.0 - sourceVector.z * sourceVector.z);
_v.x = sourceVector.y / norm;
_v.y = -sourceVector.x / norm;
_v.z = 0.0;
_v.w = 0.0;
}
}
else {
// Find the shortest angle quaternion that transforms normalized vectors
// into one other. Formula is still valid when vectors are colinear
const double s = sqrt(0.5 * dotProdPlus1);
const ofVec3f tmp = sourceVector.getCrossed(targetVector) / (2.0 * s);
_v.x = tmp.x;
_v.y = tmp.y;
_v.z = tmp.z;
_v.w = s;
}
return quat;
}
示例10: BBox2DtoVVVV
public static Vector4D BBox2DtoVVVV(this PXCMRectI32 pt, Vector2D ImageSize)
{
var bbox2d = new Vector4D();
bbox2d.z = pt.w / (float)ImageSize.x;
bbox2d.w = pt.h / (float)ImageSize.y;
bbox2d.x = (pt.x / (float)ImageSize.x * 2.0f - 1.0f) + bbox2d.z;
bbox2d.y = (1.0f - pt.y / (float)ImageSize.y * 2.0f) - bbox2d.w;
bbox2d.z *= 2;
bbox2d.w *= 2;
return bbox2d;
}
示例11: AreEqual
public void AreEqual()
{
double originalEpsilon = Numeric.EpsilonD;
Numeric.EpsilonD = 1e-8;
Vector4D u = new Vector4D(1.0, 2.0, 3.0, 4.0);
Vector4D v = new Vector4D(1.000001, 2.000001, 3.000001, 4.000001);
Vector4D w = new Vector4D(1.00000001, 2.00000001, 3.00000001, 4.00000001);
Assert.IsTrue(Vector4D.AreNumericallyEqual(u, u));
Assert.IsFalse(Vector4D.AreNumericallyEqual(u, v));
Assert.IsTrue(Vector4D.AreNumericallyEqual(u, w));
Numeric.EpsilonD = originalEpsilon;
}
示例12: ResolveShadows
public void ResolveShadows(Image shadowCastersTexture, RenderImage result, Vector2D lightPosition,
bool attenuateShadows, Image mask, Vector4D maskProps, Vector4D diffuseColor)
{
resolveShadowsEffect.Parameters["AttenuateShadows"].SetValue(attenuateShadows ? 0 : 1);
resolveShadowsEffect.Parameters["MaskProps"].SetValue(maskProps);
resolveShadowsEffect.Parameters["DiffuseColor"].SetValue(diffuseColor);
//Gorgon.CurrentRenderTarget.BlendingMode = BlendingModes.None;
ExecuteTechnique(shadowCastersTexture, distancesRT, "ComputeDistances");
ExecuteTechnique(distancesRT.Image, distortRT, "Distort");
ApplyHorizontalReduction(distortRT, shadowMap);
ExecuteTechnique(mask, result, "DrawShadows", shadowMap);
//ExecuteTechnique(shadowsRT.Image, processedShadowsRT, "BlurHorizontally");
//ExecuteTechnique(processedShadowsRT.Image, result, "BlurVerticallyAndAttenuate");
Gorgon.CurrentShader = null;
}
示例13: Absolute
public void Absolute()
{
Vector4D v = new Vector4D(-1, -2, -3, -4);
v.Absolute();
Assert.AreEqual(1, v.X);
Assert.AreEqual(2, v.Y);
Assert.AreEqual(3, v.Z);
Assert.AreEqual(4, v.W);
v = new Vector4D(1, 2, 3, 4);
v.Absolute();
Assert.AreEqual(1, v.X);
Assert.AreEqual(2, v.Y);
Assert.AreEqual(3, v.Z);
Assert.AreEqual(4, v.W);
}
示例14: AbsoluteStatic
public void AbsoluteStatic()
{
Vector4D v = new Vector4D(-1, -2, -3, -4);
Vector4D absoluteV = Vector4D.Absolute(v);
Assert.AreEqual(1, absoluteV.X);
Assert.AreEqual(2, absoluteV.Y);
Assert.AreEqual(3, absoluteV.Z);
Assert.AreEqual(4, absoluteV.W);
v = new Vector4D(1, 2, 3, 4);
absoluteV = Vector4D.Absolute(v);
Assert.AreEqual(1, absoluteV.X);
Assert.AreEqual(2, absoluteV.Y);
Assert.AreEqual(3, absoluteV.Z);
Assert.AreEqual(4, absoluteV.W);
}
示例15: Magnitude
public void Magnitude()
{
Vector4D v = new Vector4D(3.0, 4.0, 0.0, 0.0);
Assert.AreEqual(25.0, v.MagnitudeSquared, 1e-14);
Assert.AreEqual(5.0, v.Magnitude, 1e-14);
v = new Vector4D(3.0, 0.0, 4.0, 0.0);
Assert.AreEqual(25.0, v.MagnitudeSquared, 1e-14);
Assert.AreEqual(5.0, v.Magnitude, 1e-14);
v = new Vector4D(0.0, 3.0, 4.0, 0.0);
Assert.AreEqual(25.0, v.MagnitudeSquared, 1e-14);
Assert.AreEqual(5.0, v.Magnitude, 1e-14);
v = new Vector4D(0.0, 0.0, 3.0, 4.0);
Assert.AreEqual(25.0, v.MagnitudeSquared, 1e-14);
Assert.AreEqual(5.0, v.Magnitude, 1e-14);
}