本文整理汇总了C#中Vector3D.MultiplyComponents方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3D.MultiplyComponents方法的具体用法?C# Vector3D.MultiplyComponents怎么用?C# Vector3D.MultiplyComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3D
的用法示例。
在下文中一共展示了Vector3D.MultiplyComponents方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GeodeticSurfaceNormal
public Vector3D GeodeticSurfaceNormal(Vector3D positionOnEllipsoid)
{
return (positionOnEllipsoid.MultiplyComponents(_oneOverRadiiSquared)).Normalize();
}
示例2: Compute
public static Mesh Compute(Ellipsoid ellipsoid, int numberOfSubdivisions, SubdivisionEllipsoidVertexAttributes vertexAttributes)
{
if (numberOfSubdivisions < 0)
{
throw new ArgumentOutOfRangeException("numberOfSubdivisions");
}
if ((vertexAttributes & SubdivisionEllipsoidVertexAttributes.Position) != SubdivisionEllipsoidVertexAttributes.Position)
{
throw new ArgumentException("Positions must be provided.", "vertexAttributes");
}
Mesh mesh = new Mesh();
mesh.PrimitiveType = PrimitiveType.Triangles;
mesh.FrontFaceWindingOrder = WindingOrder.Counterclockwise;
int numberOfVertices = SubdivisionUtility.NumberOfVertices(numberOfSubdivisions);
VertexAttributeDoubleVector3 positionsAttribute = new VertexAttributeDoubleVector3("position", numberOfVertices);
mesh.Attributes.Add(positionsAttribute);
IndicesUnsignedInt indices = new IndicesUnsignedInt(3 * SubdivisionUtility.NumberOfTriangles(numberOfSubdivisions));
mesh.Indices = indices;
SubdivisionMesh subdivisionMesh = new SubdivisionMesh();
subdivisionMesh.Ellipsoid = ellipsoid;
subdivisionMesh.Positions = positionsAttribute.Values;
subdivisionMesh.Indices = indices;
if ((vertexAttributes & SubdivisionEllipsoidVertexAttributes.Normal) == SubdivisionEllipsoidVertexAttributes.Normal)
{
VertexAttributeHalfFloatVector3 normalsAttribute = new VertexAttributeHalfFloatVector3("normal", numberOfVertices);
mesh.Attributes.Add(normalsAttribute);
subdivisionMesh.Normals = normalsAttribute.Values;
}
if ((vertexAttributes & SubdivisionEllipsoidVertexAttributes.TextureCoordinate) == SubdivisionEllipsoidVertexAttributes.TextureCoordinate)
{
VertexAttributeHalfFloatVector2 textureCoordinateAttribute = new VertexAttributeHalfFloatVector2("textureCoordinate", numberOfVertices);
mesh.Attributes.Add(textureCoordinateAttribute);
subdivisionMesh.TextureCoordinate = textureCoordinateAttribute.Values;
}
//
// Initial tetrahedron
//
double negativeRootTwoOverThree = -Math.Sqrt(2.0) / 3.0;
const double negativeOneThird = -1.0 / 3.0;
double rootSixOverThree = Math.Sqrt(6.0) / 3.0;
Vector3D n0 = new Vector3D(0, 0, 1);
Vector3D n1 = new Vector3D(0, (2.0 * Math.Sqrt(2.0)) / 3.0, negativeOneThird);
Vector3D n2 = new Vector3D(-rootSixOverThree, negativeRootTwoOverThree, negativeOneThird);
Vector3D n3 = new Vector3D(rootSixOverThree, negativeRootTwoOverThree, negativeOneThird);
Vector3D p0 = n0.MultiplyComponents(ellipsoid.Radii);
Vector3D p1 = n1.MultiplyComponents(ellipsoid.Radii);
Vector3D p2 = n2.MultiplyComponents(ellipsoid.Radii);
Vector3D p3 = n3.MultiplyComponents(ellipsoid.Radii);
subdivisionMesh.Positions.Add(p0);
subdivisionMesh.Positions.Add(p1);
subdivisionMesh.Positions.Add(p2);
subdivisionMesh.Positions.Add(p3);
if ((subdivisionMesh.Normals != null) || (subdivisionMesh.TextureCoordinate != null))
{
Vector3D d0 = ellipsoid.GeodeticSurfaceNormal(p0);
Vector3D d1 = ellipsoid.GeodeticSurfaceNormal(p1);
Vector3D d2 = ellipsoid.GeodeticSurfaceNormal(p2);
Vector3D d3 = ellipsoid.GeodeticSurfaceNormal(p3);
if (subdivisionMesh.Normals != null)
{
subdivisionMesh.Normals.Add(d0.ToVector3H());
subdivisionMesh.Normals.Add(d1.ToVector3H());
subdivisionMesh.Normals.Add(d2.ToVector3H());
subdivisionMesh.Normals.Add(d3.ToVector3H());
}
if (subdivisionMesh.TextureCoordinate != null)
{
subdivisionMesh.TextureCoordinate.Add(SubdivisionUtility.ComputeTextureCoordinate(d0));
subdivisionMesh.TextureCoordinate.Add(SubdivisionUtility.ComputeTextureCoordinate(d1));
subdivisionMesh.TextureCoordinate.Add(SubdivisionUtility.ComputeTextureCoordinate(d2));
subdivisionMesh.TextureCoordinate.Add(SubdivisionUtility.ComputeTextureCoordinate(d3));
}
}
Subdivide(subdivisionMesh, new TriangleIndicesUnsignedInt(0, 1, 2), numberOfSubdivisions);
Subdivide(subdivisionMesh, new TriangleIndicesUnsignedInt(0, 2, 3), numberOfSubdivisions);
Subdivide(subdivisionMesh, new TriangleIndicesUnsignedInt(0, 3, 1), numberOfSubdivisions);
Subdivide(subdivisionMesh, new TriangleIndicesUnsignedInt(1, 3, 2), numberOfSubdivisions);
return mesh;
}
示例3: MultiplyComponents
public void MultiplyComponents()
{
Vector3D v1 = new Vector3D(1, 2, 3);
Vector3D v2 = new Vector3D(4, 8, 12);
Assert.AreEqual(new Vector3D(4, 16, 36), v1.MultiplyComponents(v2));
}