本文整理汇总了C#中System.Vector3.DotProduct方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.DotProduct方法的具体用法?C# Vector3.DotProduct怎么用?C# Vector3.DotProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector3
的用法示例。
在下文中一共展示了Vector3.DotProduct方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: rayPlaneIntersect
public static double[] rayPlaneIntersect(Vector3 vRayPos, Vector3 vRayDir, double[] plane)
{
Vector3 planeNormal = new Vector3 (plane[0], plane[1], plane[2]);
double denom = vRayDir.DotProduct (planeNormal);
// Calculate the denominator first
//if( Math.Abs(denom) < 0.0001f ) return null; // Make sure we won't create a divide by zero
double numer = vRayPos.DotProduct (planeNormal) + plane[3];
// Calculate the numerator next
System.Console.WriteLine (denom.ToString () + " " + numer.ToString ());
double time = -numer / denom;
// Get the time of intersection
Vector3 result = new Vector3 ((time * vRayDir) + vRayPos);
// Return the point of intersection
return result.Position ();
}
示例2: modify
//--------------------------------------------------------------
public void modify() {
if (mInputTriangleBuffer == null)
OGRE_EXCEPT("Exception::ERR_INVALID_STATE", "Input triangle buffer must be set", "__FUNCTION__");
;
Vector3[] directions = new Vector3[6] { Vector3.UNIT_X, Vector3.UNIT_Y, Vector3.UNIT_Z, Vector3.NEGATIVE_UNIT_X, Vector3.NEGATIVE_UNIT_Y, Vector3.NEGATIVE_UNIT_Z };
//for (List<TriangleBuffer.Vertex>.Enumerator it = mInputTriangleBuffer.getVertices().begin(); it != mInputTriangleBuffer.getVertices().end(); ++it)
foreach (var it in mInputTriangleBuffer.getVertices()) {
Vector3 v = it.mPosition - mBoxCenter;
if (v.IsZeroLength)
continue;
//v.normalise();
v.x /= mBoxSize.x;
v.y /= mBoxSize.y;
v.z /= mBoxSize.z;
//C++ TO C# CONVERTER WARNING: The following line was determined to be a copy constructor call - this should be verified and a copy constructor should be created if it does not yet exist:
//ORIGINAL LINE: Vector3 n = it->mNormal;
Vector3 n = (it.mNormal);
float maxAxis = 0;
int principalAxis = 0;
for (byte i = 0; i < 6; i++) {
if (directions[i].DotProduct(n) > maxAxis) {
maxAxis = directions[i].DotProduct(n);
principalAxis = i;
}
}
Vector3 vX = new Vector3();
Vector3 vY = new Vector3();
if (principalAxis % 3 == 1)
vY = Vector3.UNIT_X;
else
vY = Vector3.UNIT_Y;
vX = directions[principalAxis].CrossProduct(vY);
Vector2 uv = new Vector2(0.5f - vX.DotProduct(v), 0.5f - vY.DotProduct(v));
if (mMappingType == MappingType.MT_FULL)
it.mUV = uv;
else if (mMappingType == MappingType.MT_CROSS) {
}
else if (mMappingType == MappingType.MT_PACKED)
it.mUV = new Vector2((uv.x + principalAxis % 3) / 3, (uv.y + principalAxis / 3) / 2);
}
}
示例3: angleBetween
public static Radian angleBetween(Vector3 v1, Vector3 dest) {
float lenProduct = v1.Length * dest.Length;
// Divide by zero check
if (lenProduct < 1e-6f)
lenProduct = 1e-6f;
float f = v1.DotProduct(dest) / lenProduct;
f = Clamp(f, (float)-1.0f, 1.0f);
return Math.ACos(f);
}
示例4: ComputeFaceUVCoordinates
/// <summary>
/// Calculates absolute UV values for all points of a face.
/// </summary>
/// <param name="faceVertsIn">Source array of native point values.</param>
/// <param name="faceVertsOut">Destination array for calculated UV values.</param>
/// <returns>True if successful, otherwise false.</returns>
public bool ComputeFaceUVCoordinates(ref DFPurePoint[] faceVertsIn, ref DFPurePoint[] faceVertsOut)
{
// Get first three vertices of ngon (these three vertices are always non-collinear)
Vector3 P0 = new Vector3(faceVertsIn[0].x, faceVertsIn[0].y, faceVertsIn[0].z);
Vector3 P1 = new Vector3(faceVertsIn[1].x, faceVertsIn[1].y, faceVertsIn[1].z);
Vector3 P2 = new Vector3(faceVertsIn[2].x, faceVertsIn[2].y, faceVertsIn[2].z);
// Create coplanar vectors from p1->p0 and p2->p0
Vector3 V0 = P1 - P0;
Vector3 V1 = P2 - P0;
// Orthogonalize V1
V1 = V1 - (V0 * (V1.DotProduct(V0) / (V0.DotProduct(V0))));
// Normalize both vectors
V0.Normalize();
V1.Normalize();
// Compute first three vertices in 2D space
DF2DPoint p0, p1, p2;
p0.x = (Int32)P0.DotProduct(V0);
p0.y = (Int32)P0.DotProduct(V1);
p1.x = (Int32)P1.DotProduct(V0);
p1.y = (Int32)P1.DotProduct(V1);
p2.x = (Int32)P2.DotProduct(V0);
p2.y = (Int32)P2.DotProduct(V1);
// Initialise the params struct
df3duvparams_lt Params = new df3duvparams_lt();
Params.X = new float[4];
Params.Y = new float[4];
Params.Z = new float[4];
Params.U = new float[4];
Params.V = new float[4];
// Initialise the conversion matrix
df3duvmatrix_t Matrix = new df3duvmatrix_t();
Matrix.UA = 1.0f;
Matrix.UB = 0.0f;
Matrix.UC = 0.0f;
Matrix.UD = 0.0f;
Matrix.VA = 0.0f;
Matrix.VB = 1.0f;
Matrix.VC = 0.0f;
Matrix.UD = 0.0f;
// Store the first 3 points of texture coordinates
Params.U[0] = faceVertsIn[0].u;
Params.U[1] = faceVertsIn[1].u + Params.U[0];
Params.U[2] = faceVertsIn[2].u + Params.U[1];
Params.V[0] = faceVertsIn[0].v;
Params.V[1] = faceVertsIn[1].v + Params.V[0];
Params.V[2] = faceVertsIn[2].v + Params.V[1];
// Get and store the 1st point coordinates in face
Params.X[0] = p0.x;
Params.Y[0] = p0.y;
Params.Z[0] = 0;
// Get and store the 2nd point coordinates in face
Params.X[1] = p1.x;
Params.Y[1] = p1.y;
Params.Z[1] = 0;
// Get and store the 3rd point coordinates in face
Params.X[2] = p2.x;
Params.Y[2] = p2.y;
Params.Z[2] = 0;
// Compute the solution using an XY linear equation
if (!l_ComputeDFUVMatrixXY(ref Matrix, ref Params))
return false;
// Assign matrix to all points if successful
Int32 u = 0, v = 0;
for (int point = 0; point < faceVertsIn.Length; point++)
{
if (point > 2)
{
// Use generated matrix to calculate UV value from 2D point
DF2DPoint pn;
Vector3 PN = new Vector3(faceVertsIn[point].x, faceVertsIn[point].y, faceVertsIn[point].z);
pn.x = (Int32)PN.DotProduct(V0);
pn.y = (Int32)PN.DotProduct(V1);
u = (Int32)((pn.x * Matrix.UA) + (pn.y * Matrix.UB) + Matrix.UD);
v = (Int32)((pn.x * Matrix.VA) + (pn.y * Matrix.VB) + Matrix.VD);
}
else if (point == 0)
{
// UV[0] is absolute
u = faceVertsIn[0].u;
v = faceVertsIn[0].v;
}
else if (point == 1)
//.........这里部分代码省略.........