本文整理汇总了C#中Vector3.equals2方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.equals2方法的具体用法?C# Vector3.equals2怎么用?C# Vector3.equals2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3
的用法示例。
在下文中一共展示了Vector3.equals2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RaycastWithEdges
/// <summary>
/// 从edges开始检查, 获取将半径为radius的物体, 从from移动到to, 可达的最远位置.
/// </summary>
Vector3 RaycastWithEdges(IEnumerable<HalfEdge> edges, Vector3 from, Vector3 to, float radius)
{
if (from.equals2(to))
{
return to;
}
Vector2 segCrossAnswer = Vector2.zero;
foreach (HalfEdge edge in edges)
{
// 检查相交.
CrossState crossState = MathUtility.SegmentCross(out segCrossAnswer, from, to, edge.Src.Position, edge.Dest.Position);
Utility.Verify(crossState == CrossState.CrossOnSegment || crossState == CrossState.CrossOnExtLine);
// 交点不在线段上.
if (segCrossAnswer.x < 0 || segCrossAnswer.x > 1) { continue; }
// 如果交点在线段上, 那么表示该交点为当前最远位置. 再继续从这条边开始检查.
if (crossState == CrossState.CrossOnSegment)
{
Vector3 cross = from + segCrossAnswer.x * (to - from);
to = RaycastFromEdge(edge, cross, to, radius);
break;
}
}
return to;
}
示例2: FindCrossedEdge
/// <summary>
/// 查找ray的环中, 与src->dest的边相交的边.
/// </summary>
bool FindCrossedEdge(out Tuple2<HalfEdge, CrossState> answer, HalfEdge ray, Vector3 src, Vector3 dest)
{
List<HalfEdge> cycle = ray.Cycle;
answer = new Tuple2<HalfEdge, CrossState>();
foreach (HalfEdge edge in cycle)
{
Vector3 point;
CrossState crossState = MathUtility.GetLineCrossPoint(out point,
edge.Src.Position, edge.Dest.Position,
src, dest
);
if (crossState == CrossState.FullyOverlaps
|| (crossState == CrossState.CrossOnSegment && !point.equals2(edge.Src.Position) && !point.equals2(edge.Dest.Position)))
{
answer.Second = crossState;
answer.First = edge;
if (crossState == CrossState.FullyOverlaps
&& (dest.equals2(edge.Src.Position) || src.equals2(edge.Dest.Position)))
{
answer.First = answer.First.Pair;
}
return true;
}
}
return false;
}
示例3: RaycastFromEdge
/// <summary>
/// from在edge上, 查找半径为radius的物体从from到to可达的最远位置.
/// </summary>
Vector3 RaycastFromEdge(HalfEdge edge, Vector3 from, Vector3 to, float radius)
{
// 起点==终点, 或者edge为约束边.
if (from.equals2(to) || edge.Constrained || edge.Pair.Constrained)
{
return from;
}
// from位置无效.
if (!IsValidPosition(from, radius))
{
return from;
}
// 根据from->to的方向, 确定下一个要访问的三角形是edge.Face还是edge.Pair.Face.
if ((to - from).cross2(edge.Dest.Position - edge.Src.Position) > 0)
{
edge = edge.Pair;
}
// 不存在另一边的三角形.
if (edge.Face == null)
{
return from;
}
// 检查另外两条边.
return RaycastWithEdges(new HalfEdge[] { edge.Next, edge.Next.Next }, from, to, radius);
}