本文整理汇总了C#中Vector3d.cross方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3d.cross方法的具体用法?C# Vector3d.cross怎么用?C# Vector3d.cross使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3d
的用法示例。
在下文中一共展示了Vector3d.cross方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Line
//----------------------------------CONSTRUCTORS---------------------------------//
/**
* Constructor for a line. The line created is the intersection between two planes
*
* @param face1 face representing one of the planes
* @param face2 face representing one of the planes
*/
public Line(Face face1, Face face2)
{
Vector3d normalFace1 = face1.getNormal();
Vector3d normalFace2 = face2.getNormal();
//direction: cross product of the faces normals
direction = new Vector3d();
direction.cross(normalFace1, normalFace2);
//if direction lenght is not zero (the planes aren't parallel )...
if (!(direction.length() < TOL))
{
//getting a line point, zero is set to a coordinate whose direction
//component isn't zero (line intersecting its origin plan)
point = new Point3d();
double d1 = -(normalFace1.x * face1.v1.x + normalFace1.y * face1.v1.y + normalFace1.z * face1.v1.z);
double d2 = -(normalFace2.x * face2.v1.x + normalFace2.y * face2.v1.y + normalFace2.z * face2.v1.z);
if (Math.Abs(direction.x) > TOL)
{
point.x = 0;
point.y = (d2 * normalFace1.z - d1 * normalFace2.z) / direction.x;
point.z = (d1 * normalFace2.y - d2 * normalFace1.y) / direction.x;
}
else if (Math.Abs(direction.y) > TOL)
{
point.x = (d1 * normalFace2.z - d2 * normalFace1.z) / direction.y;
point.y = 0;
point.z = (d2 * normalFace1.x - d1 * normalFace2.x) / direction.y;
}
else
{
point.x = (d2 * normalFace1.y - d1 * normalFace2.y) / direction.z;
point.y = (d1 * normalFace2.x - d2 * normalFace1.x) / direction.z;
point.z = 0;
}
}
direction.normalize();
}
示例2: getNormal
/**
* Gets the face normal
*
* @return face normal
*/
public Vector3d getNormal()
{
Point3d p1 = v1.getPosition();
Point3d p2 = v2.getPosition();
Point3d p3 = v3.getPosition();
Vector3d xy, xz, normal;
xy = new Vector3d(p2.x - p1.x, p2.y - p1.y, p2.z - p1.z);
xz = new Vector3d(p3.x - p1.x, p3.y - p1.y, p3.z - p1.z);
normal = new Vector3d();
normal.cross(xy, xz);
normal.normalize();
return normal;
}