本文整理汇总了C#中System.Line.Transform方法的典型用法代码示例。如果您正苦于以下问题:C# Line.Transform方法的具体用法?C# Line.Transform怎么用?C# Line.Transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Line
的用法示例。
在下文中一共展示了Line.Transform方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: hodgeStar
void hodgeStar(List<leaf> _listLeaf, List<branch> _listBranch, Func<double, double> coeff,double sScale)
{
foreach (var branch in _listBranch)
{
for (int i = 0; i < branch.tuples.Count(); i++)
{
double g = branch.tuples[i].gij[0, 0];
double val = coeff(g);
branch.tuples[i].SPK[0, 0] = branch.tuples[i].H[0, 0] * val*sScale;
/*if (branch.tuples[i].SPK[0, 0] <= 0)
{
branch.tuples[i].SPK[0, 0] = 0.00000000000001d;//E-14
}*/
}
}
foreach (var leaf in _listLeaf)
{
for (int j = 0; j < leaf.r; j++)
{
//Hodge star
double g = leaf.tuples[j].refDv * leaf.tuples[j].refDv;
leaf.tuples[j].SPK[0, 0] = leaf.tuples[j].H[1, 1] / g;
leaf.tuples[j].SPK[1, 1] = leaf.tuples[j].H[0, 0] / g;
leaf.tuples[j].SPK[0, 1] = -leaf.tuples[j].H[0, 1] / g;
leaf.tuples[j].SPK[1, 0] = -leaf.tuples[j].H[1, 0] / g;
leaf.tuples[j].computeEigenVectors();
var tup = leaf.tuples[j];
var det = tup.SPK[0, 0] * tup.SPK[1, 1] - tup.SPK[0, 1] * tup.SPK[1, 0];
/*if (tup.eigenValues[0] < 0 || tup.eigenValues[1] < 0)
{
if (tup.eigenValues[0] < 0) tup.eigenValues[0] = 0.00000000000001d;//E-14
if (tup.eigenValues[1] < 0) tup.eigenValues[1] = 0.00000000000001d;//E-14
//P
double A11 = tup.eigenVectorsB[0][0];
double A12 = tup.eigenVectorsB[0][1];
double A21 = tup.eigenVectorsB[1][0];
double A22 = tup.eigenVectorsB[1][1];
double det2 = A11 * A22 - A12 * A21;
//P^-1
double B11 = A22 / det2;
double B22 = A11 / det2;
double B12 = -A12 / det2;
double B21 = -A21 / det2;
double C11 = B11 * tup.eigenValues[0];
double C12 = B12 * tup.eigenValues[1];
double C21 = B21 * tup.eigenValues[0];
double C22 = B22 * tup.eigenValues[1];
double D11 = C11 * A11 + C12 * A21;
double D12 = C11 * A12 + C12 * A22;
double D21 = C21 * A11 + C22 * A21;
double D22 = C21 * A12 + C22 * A22;
tup.SPK[0, 0] = D11 * tup.Gij[0, 0] + D12 * tup.Gij[1, 0];
tup.SPK[0, 1] = D11 * tup.Gij[0, 1] + D12 * tup.Gij[1, 1];
tup.SPK[1, 0] = D21 * tup.Gij[0, 0] + D22 * tup.Gij[1, 0];
tup.SPK[1, 1] = D21 * tup.Gij[1, 0] + D22 * tup.Gij[1, 1];
}*/
tup.SPK[0, 0] *= sScale;
tup.SPK[1, 0] *= sScale;
tup.SPK[0, 1] *= sScale;
tup.SPK[1, 1] *= sScale;
}
}
//For visualization
crossMagenta.Clear();
crossCyan.Clear();
foreach (var leaf in listLeaf)
{
foreach (var tuple in leaf.tuples)
{
for (int i = 0; i < 2; i++)
{
if (tuple.eigenValues[i] < 0)
{
double s = tuple.eigenValues[i]*sScale;
//double s = 0.1;
Point3d S = new Point3d(tuple.x - tuple.eigenVectors[i][0] * s, tuple.y - tuple.eigenVectors[i][1] * s, tuple.z - tuple.eigenVectors[i][2] * s);
Point3d E = new Point3d(tuple.x + tuple.eigenVectors[i][0] * s, tuple.y + tuple.eigenVectors[i][1] * s, tuple.z + tuple.eigenVectors[i][2] * s);
Line line = new Line(S, E);
line.Transform(zDown);
crossCyan.Add(line);
}
else
{
double s = tuple.eigenValues[i]*sScale;
//double s = 0.1;
Point3d S = new Point3d(tuple.x - tuple.eigenVectors[i][0] * s, tuple.y - tuple.eigenVectors[i][1] * s, tuple.z - tuple.eigenVectors[i][2] * s);
Point3d E = new Point3d(tuple.x + tuple.eigenVectors[i][0] * s, tuple.y + tuple.eigenVectors[i][1] * s, tuple.z + tuple.eigenVectors[i][2] * s);
Line line = new Line(S, E);
line.Transform(zDown);
crossMagenta.Add(line);
}
}
}
}
}
示例2: DiamondLines
private List<Line> DiamondLines(double d)
{
var lines = new List<Line>();
var nodes = new List<Point3d>();
//corner points
nodes.Add(new Point3d(0, 0, 0));
// face-centered points
nodes.Add(new Point3d(0, d / 2, d / 2));
nodes.Add(new Point3d(d / 2, 0 , d / 2));
nodes.Add(new Point3d(d / 2, d / 2, 0));
// others
nodes.Add(new Point3d(d/4, d/4, d/4));
lines.Add(new Line(nodes[4], nodes[0]));
lines.Add(new Line(nodes[4], nodes[1]));
lines.Add(new Line(nodes[4], nodes[2]));
lines.Add(new Line(nodes[4], nodes[3]));
var lines2 = new List<Line>(lines);
foreach (var line in lines)
{
var newLine = new Line(line.From, line.To);
newLine.Transform(Transform.Translation(d / 2, d / 2, 0));
lines2.Add(newLine);
}
foreach (var line in lines)
{
var newLine = new Line(line.From, line.To);
newLine.Transform(Transform.Rotation(Math.PI / 2, nodes[4]));
newLine.Transform(Transform.Translation(d / 2, d / 2, d/2));
lines2.Add(newLine);
}
foreach (var line in lines)
{
var newLine = new Line(line.From, line.To);
newLine.Transform(Transform.Rotation(Math.PI / 2, nodes[4]));
newLine.Transform(Transform.Translation(0, 0, d / 2));
lines2.Add(newLine);
}
lines.AddRange(lines2);
return lines;
}
示例3: QuadFaceOffset
public Polyline QuadFaceOffset(Point3d p1, Point3d p2, Point3d p3, Point3d p4, Vector3d N, double distance)
{
Point3d cen = (p1 + p2 + p3 + p4) / 4;
Line lcen = new Line(cen, cen + N);
double u, v;
Line l1 = new Line(p1, p2);
Rhino.Geometry.Intersect.Intersection.LineLine(lcen, l1, out u, out v);
Vector3d v1 = lcen.PointAt(u) - l1.PointAt(v);
v1.Unitize(); v1 *= distance;
l1.Transform(Transform.Translation(v1));
Line l2 = new Line(p2, p3);
Rhino.Geometry.Intersect.Intersection.LineLine(lcen, l2, out u, out v);
v1 = lcen.PointAt(u) - l2.PointAt(v);
v1.Unitize(); v1 *= distance;
l2.Transform(Transform.Translation(v1));
Line l3 = new Line(p3, p4);
Rhino.Geometry.Intersect.Intersection.LineLine(lcen, l3, out u, out v);
v1 = lcen.PointAt(u) - l3.PointAt(v);
v1.Unitize(); v1 *= distance;
l3.Transform(Transform.Translation(v1));
Line l4 = new Line(p4, p1);
Rhino.Geometry.Intersect.Intersection.LineLine(lcen, l4, out u, out v);
v1 = lcen.PointAt(u) - l4.PointAt(v);
v1.Unitize(); v1 *= distance;
l4.Transform(Transform.Translation(v1));
Polyline output = new Polyline();
Rhino.Geometry.Intersect.Intersection.LineLine(l1, l4, out u, out v);
output.Add((l1.PointAt(u) + l4.PointAt(v)) / 2);
Rhino.Geometry.Intersect.Intersection.LineLine(l2, l1, out u, out v);
output.Add((l2.PointAt(u) + l1.PointAt(v)) / 2);
Rhino.Geometry.Intersect.Intersection.LineLine(l3, l2, out u, out v);
output.Add((l3.PointAt(u) + l2.PointAt(v)) / 2);
Rhino.Geometry.Intersect.Intersection.LineLine(l4, l3, out u, out v);
output.Add((l4.PointAt(u) + l3.PointAt(v)) / 2);
return output;
}
示例4: LineBox
/// <summary>
/// Intersects an infinite line with a box volume.
/// </summary>
/// <param name="box">Box to intersect.</param>
/// <param name="line">Line for intersection.</param>
/// <param name="tolerance">
/// If tolerance > 0.0, then the intersection is performed against a box
/// that has each side moved out by tolerance.
/// </param>
/// <param name="lineParameters">
/// The chord from line.PointAt(lineParameters.T0) to line.PointAt(lineParameters.T1) is the intersection.
/// </param>
/// <returns>true if the line intersects the box, false if no intersection occurs.</returns>
public static bool LineBox(Line line, Box box, double tolerance, out Interval lineParameters)
{
//David: test this!
BoundingBox bbox = new BoundingBox(new Point3d(box.X.Min, box.Y.Min, box.Z.Min),
new Point3d(box.X.Max, box.Y.Max, box.Z.Max));
Transform xform = Transform.ChangeBasis(Plane.WorldXY, box.Plane);
line.Transform(xform);
return LineBox(line, bbox, tolerance, out lineParameters);
}
示例5: MeshWindow
///// MeshCreation
public Mesh MeshWindow(Mesh mesh, double t)
{
Mesh output = new Mesh();
mesh.FaceNormals.ComputeFaceNormals();
for (int i = 0; i < mesh.Faces.Count; i++)
{
MeshFace mf = mesh.Faces[i];
if (mf.IsTriangle)
{
Point3d p1 = mesh.Vertices[mf.A];
Point3d p2 = mesh.Vertices[mf.B];
Point3d p3 = mesh.Vertices[mf.C];
Line l1 = new Line(p1, p2);
Line l2 = new Line(p2, p3);
Line l3 = new Line(p3, p1);
Vector3d v1 = Vector3d.CrossProduct(p2 - p1, mesh.FaceNormals[i]);
v1.Unitize(); v1 *= -t;
Vector3d v2 = Vector3d.CrossProduct(p3 - p2, mesh.FaceNormals[i]);
v2.Unitize(); v2 *= -t;
Vector3d v3 = Vector3d.CrossProduct(p1 - p3, mesh.FaceNormals[i]);
v3.Unitize(); v3 *= -t;
l1.Transform(Transform.Translation(v1));
l2.Transform(Transform.Translation(v2));
l3.Transform(Transform.Translation(v3));
double t1, t2, t3;
Rhino.Geometry.Intersect.Intersection.LineLine(l1, l2, out t1, out t2);
p2 = (l1.PointAt(t1) + l2.PointAt(t2)) / 2;
Rhino.Geometry.Intersect.Intersection.LineLine(l2, l3, out t2, out t3);
p3 = (l3.PointAt(t3) + l2.PointAt(t2)) / 2;
Rhino.Geometry.Intersect.Intersection.LineLine(l3, l1, out t3, out t1);
p1 = (l1.PointAt(t1) + l3.PointAt(t3)) / 2;
int index1 = output.Vertices.Count;
output.Vertices.Add(p1);
output.Vertices.Add(p2);
output.Vertices.Add(p3);
output.Faces.AddFace(index1, index1 + 1, index1 + 2);
}
if (mf.IsQuad)
{
Point3d p1 = mesh.Vertices[mesh.Faces[i].A];
Point3d p2 = mesh.Vertices[mesh.Faces[i].B];
Point3d p3 = mesh.Vertices[mesh.Faces[i].C];
Point3d p4 = mesh.Vertices[mesh.Faces[i].D];
Line l1 = new Line(p1, p2);
Line l2 = new Line(p2, p3);
Line l3 = new Line(p3, p4);
Line l4 = new Line(p4, p1);
Vector3d v1 = Vector3d.CrossProduct(p2 - p1, mesh.FaceNormals[i]);
v1.Unitize(); v1 *= -t;
Vector3d v2 = Vector3d.CrossProduct(p3 - p2, mesh.FaceNormals[i]);
v2.Unitize(); v2 *= -t;
Vector3d v3 = Vector3d.CrossProduct(p4 - p3, mesh.FaceNormals[i]);
v3.Unitize(); v3 *= -t;
Vector3d v4 = Vector3d.CrossProduct(p1 - p4, mesh.FaceNormals[i]);
v4.Unitize(); v4 *= -t;
l1.Transform(Transform.Translation(v1));
l2.Transform(Transform.Translation(v2));
l3.Transform(Transform.Translation(v3));
l4.Transform(Transform.Translation(v4));
double t1, t2, t3, t4;
Rhino.Geometry.Intersect.Intersection.LineLine(l1, l2, out t1, out t2);
p2 = (l1.PointAt(t1) + l2.PointAt(t2)) / 2;
Rhino.Geometry.Intersect.Intersection.LineLine(l2, l3, out t2, out t3);
p3 = (l3.PointAt(t3) + l2.PointAt(t2)) / 2;
Rhino.Geometry.Intersect.Intersection.LineLine(l3, l4, out t3, out t4);
p4 = (l4.PointAt(t4) + l3.PointAt(t3)) / 2;
Rhino.Geometry.Intersect.Intersection.LineLine(l4, l1, out t4, out t1);
p1 = (l1.PointAt(t1) + l4.PointAt(t4)) / 2;
int index1 = output.Vertices.Count;
output.Vertices.Add(p1);
output.Vertices.Add(p2);
output.Vertices.Add(p3);
output.Vertices.Add(p4);
output.Faces.AddFace(index1, index1 + 1, index1 + 2, index1 + 3);
}
}
output.UnifyNormals();
return output;
}