本文整理汇总了C#中System.Line.Project方法的典型用法代码示例。如果您正苦于以下问题:C# Line.Project方法的具体用法?C# Line.Project怎么用?C# Line.Project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Line
的用法示例。
在下文中一共展示了Line.Project方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DelayedHitCalc
public override RealHitInfo DelayedHitCalc(Line by, HitInfo hit)
{
RealHitInfo realHit = new RealHitInfo();
realHit.HitStuff = Surface;
realHit.Pigment = Pigment;
realHit.Normal = new Line();
realHit.Normal.Start = by.Project(hit.HitDist);
realHit.Normal.Direct.Dx = 0;
realHit.Normal.Direct.Dy = 0;
realHit.Normal.Direct.Dz = 0;
switch (hit.SurfaceIndex)
{
case 0:
Point hitLoc2 = inv.Apply(realHit.Normal.Start);
realHit.Normal.Direct.Dx = hitLoc2.X;
realHit.Normal.Direct.Dy = hitLoc2.Y;
realHit.Normal.Direct.Dz = hitLoc2.Z;
break;
default:
throw new InvalidOperationException("Invalid surface index in hitdata");
}
Vector before = realHit.Normal.Direct;
realHit.Normal.Direct = trans.Apply(realHit.Normal.Direct);
if (realHit.Normal.Direct.Dot(by.Direct) > 0)
{
realHit.Normal.Direct.ScaleSelf(-1.0);
}
return realHit;
}
示例2: DelayedHitCalc
public override RealHitInfo DelayedHitCalc(Line by, HitInfo hit)
{
RealHitInfo realHit = new RealHitInfo();
realHit.Normal = new Line();
realHit.HitStuff = Surface;
realHit.Pigment = Pigment;
realHit.Normal.Start = by.Project(hit.HitDist);
realHit.Normal.Direct.Dx = 0;
realHit.Normal.Direct.Dy = 0;
realHit.Normal.Direct.Dz = 0;
Point hitLoc;
Vector deviance = new Vector();
if (rounded)
{
hitLoc = inv.Apply(realHit.Normal.Start);
if (hit.SurfaceIndex != 5 || !RoundedTopOnly)
{
if (hitLoc.X < -1 + XRounding)
{
switch (hit.SurfaceIndex)
{
case 2:
case 3:
case 4:
case 5:
deviance.Dx = -1 + (hitLoc.X + 1) / XRounding;
break;
}
}
if (hitLoc.X > 1 - XRounding)
{
switch (hit.SurfaceIndex)
{
case 2:
case 3:
case 4:
case 5:
deviance.Dx = 1 - (1 - hitLoc.X) / XRounding;
break;
}
}
if (hitLoc.Y < -1 + YRounding)
{
switch (hit.SurfaceIndex)
{
case 0:
case 1:
case 4:
case 5:
deviance.Dy = -1 + (hitLoc.Y + 1) / YRounding;
break;
}
}
if (hitLoc.Y > 1 - YRounding)
{
switch (hit.SurfaceIndex)
{
case 0:
case 1:
case 4:
case 5:
deviance.Dy = 1 - (1 - hitLoc.Y) / YRounding;
break;
}
}
}
if (!RoundedTopOnly && hitLoc.Z < -1 + ZRounding)
{
switch (hit.SurfaceIndex)
{
case 0:
case 1:
case 2:
case 3:
deviance.Dz = -1 +(hitLoc.Z + 1) / ZRounding;
break;
}
}
if (hitLoc.Z > 1 - ZRounding)
{
switch (hit.SurfaceIndex)
{
case 0:
case 1:
case 2:
case 3:
deviance.Dz = 1 - (1 - hitLoc.Z) / ZRounding;
break;
}
}
}
switch (hit.SurfaceIndex)
{
case 0:
realHit.Normal.Direct.Dx = 1;
break;
case 1:
realHit.Normal.Direct.Dx = -1;
break;
case 2:
//.........这里部分代码省略.........
示例3: DelayedHitCalc
public override RealHitInfo DelayedHitCalc(Line by, HitInfo hit)
{
RealHitInfo realHit = new RealHitInfo();
realHit.HitStuff = Surface;
realHit.Pigment = Pigment;
realHit.Normal = new Line();
realHit.Normal.Start = by.Project(hit.HitDist);
realHit.Normal.Direct.Dx = 0;
realHit.Normal.Direct.Dy = 0;
realHit.Normal.Direct.Dz = 0;
Point hitLoc;
Vector deviance = new Vector();
if (rounded)
{
hitLoc = inv.Apply(realHit.Normal.Start);
if (hit.SurfaceIndex == 1 || (!RoundedTopOnly && hit.SurfaceIndex == 2))
{
double r = Math.Sqrt(hitLoc.X * hitLoc.X + hitLoc.Y * hitLoc.Y);
if (r > 1 - RRounding)
{
double dr = (1 - (1 - r) / RRounding) / (r);
deviance.Dx = hitLoc.X * dr;
deviance.Dy = hitLoc.Y * dr;
}
}
if (!RoundedTopOnly && hitLoc.Z < -1 + ZRounding)
{
switch (hit.SurfaceIndex)
{
case 0:
deviance.Dz = -1 + (hitLoc.Z + 1) / ZRounding;
break;
}
}
if (hitLoc.Z > 1 - ZRounding)
{
switch (hit.SurfaceIndex)
{
case 0:
deviance.Dz = 1 - (1 - hitLoc.Z) / ZRounding;
break;
}
}
}
switch (hit.SurfaceIndex)
{
case 0:
Point hitLoc2 = inv.Apply(realHit.Normal.Start);
realHit.Normal.Direct.Dx = hitLoc2.X;
realHit.Normal.Direct.Dy = hitLoc2.Y;
break;
case 1:
realHit.Normal.Direct.Dz = 1;
break;
case 2:
realHit.Normal.Direct.Dz = -1;
break;
default:
throw new InvalidOperationException("Invalid surface index in hitdata");
}
Vector before = realHit.Normal.Direct;
realHit.Normal.Direct = trans.Apply(realHit.Normal.Direct);
if (realHit.Normal.Direct.Dot(by.Direct) > 0)
{
if (rounded)
{
before.ScaleSelf(-1.0);
deviance.ScaleSelf(-1.0);
}
else
realHit.Normal.Direct.ScaleSelf(-1.0);
}
if (rounded)
{
realHit.Normal.Direct = before;
realHit.Normal.Direct.Add(deviance);
realHit.Normal.Direct = trans.Apply(realHit.Normal.Direct);
if (realHit.Normal.Direct.Dot(by.Direct) > 0)
{
Vector perp1 = realHit.Normal.Direct.Cross(by.Direct);
realHit.Normal.Direct = by.Direct.Cross(perp1);
}
}
return realHit;
}
示例4: AreLinesEqual
private bool AreLinesEqual(Line line1, Line line2)
{
if (!line1.IsBound || !line2.IsBound)
{
// Two unbound lines are equal if they are going in the same direction and the origin
// of one lies on the other one.
return line1.Direction.IsAlmostEqualTo(line2.Direction) &&
MathUtil.IsAlmostZero(line1.Project(line2.Origin).Distance);
}
for (int ii = 0; ii < 2; ii++)
{
if (line1.GetEndPoint(0).IsAlmostEqualTo(line2.GetEndPoint(ii)) &&
line1.GetEndPoint(1).IsAlmostEqualTo(line2.GetEndPoint(1 - ii)))
return true;
}
return false;
}