Class GeoGraph2D
Inheritance
System.Object
GeoGraph2D
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Assembly: cs.temp.dll.dll
Syntax
public static class GeoGraph2D
Fields
Epsilon
Declaration
public const float Epsilon = 1E-05F
Field Value
Type |
Description |
System.Single |
|
Methods
CalcLerpPointInLine(Ray2D, Ray2D, Single, out Vector2)
直線a,bがあり. |a.origin-pos|とdistance(pos, b)の比率がp:1-pとなるようなA上点posを返す
Declaration
public static bool CalcLerpPointInLine(Ray2D a, Ray2D b, float p, out Vector2 pos)
Parameters
Type |
Name |
Description |
Ray2D |
a |
|
Ray2D |
b |
|
System.Single |
p |
|
Vector2 |
pos |
|
Returns
Type |
Description |
System.Boolean |
|
CalcPolygonArea(IReadOnlyList<Vector2>)
Declaration
public static float CalcPolygonArea(IReadOnlyList<Vector2> vertices)
Parameters
Type |
Name |
Description |
IReadOnlyList<Vector2> |
vertices |
|
Returns
Type |
Description |
System.Single |
|
CalcPolygonArea<T>(IReadOnlyList<T>, Func<T, Vector2>)
Declaration
public static float CalcPolygonArea<T>(IReadOnlyList<T> vertices, Func<T, Vector2> toVec2)
Parameters
Type |
Name |
Description |
IReadOnlyList<T> |
vertices |
|
Func<T, Vector2> |
toVec2 |
|
Returns
Type |
Description |
System.Single |
|
Type Parameters
ComputeConvexVolume(IEnumerable<Vector2>)
Declaration
public static List<Vector2> ComputeConvexVolume(IEnumerable<Vector2> vertices)
Parameters
Type |
Name |
Description |
IEnumerable<Vector2> |
vertices |
|
Returns
Type |
Description |
List<Vector2> |
|
ComputeConvexVolume(IEnumerable<Vector3>, Func<Vector3, Vector2>)
Vector3の頂点をtoVec2で2Dに射影したうえで凸包を構成する頂点を返す
Declaration
public static List<Vector3> ComputeConvexVolume(IEnumerable<Vector3> vertices, Func<Vector3, Vector2> toVec2)
Parameters
Type |
Name |
Description |
IEnumerable<Vector3> |
vertices |
|
Func<Vector3, Vector2> |
toVec2 |
|
Returns
Type |
Description |
List<Vector3> |
|
ComputeConvexVolume<T>(IEnumerable<T>, Func<T, Vector3>, AxisPlane, Single)
凸包を計算する. 戻り値の0番,^1番は同じものが入る
Declaration
public static List<T> ComputeConvexVolume<T>(IEnumerable<T> vertices, Func<T, Vector3> toVec3, AxisPlane plane, float sameLineTolerance = 0F)
Parameters
Type |
Name |
Description |
IEnumerable<T> |
vertices |
|
Func<T, Vector3> |
toVec3 |
|
AxisPlane |
plane |
|
System.Single |
sameLineTolerance |
同一直線の許容誤差. 2つのベクトルの内積が1-これ以上
|
Returns
Type Parameters
ComputeMeshOutlineVertices(IReadOnlyList<Vector3>, IList<Int32>, Func<Vector3, Vector2>, Single)
Declaration
public static List<Vector3> ComputeMeshOutlineVertices(IReadOnlyList<Vector3> vert, IList<int> triangles, Func<Vector3, Vector2> toVec2, float epsilon = 0.1F)
Parameters
Type |
Name |
Description |
IReadOnlyList<Vector3> |
vert |
|
IList<System.Int32> |
triangles |
|
Func<Vector3, Vector2> |
toVec2 |
|
System.Single |
epsilon |
|
Returns
Type |
Description |
List<Vector3> |
|
ComputeMeshOutlineVertices(SubDividedCityObject.Mesh, SubDividedCityObject.SubMesh, Func<Vector3, Vector2>, Single)
Declaration
public static List<Vector3> ComputeMeshOutlineVertices(SubDividedCityObject.Mesh mesh, SubDividedCityObject.SubMesh subMesh, Func<Vector3, Vector2> toVec2, float epsilon = 0.1F)
Parameters
Type |
Name |
Description |
SubDividedCityObject.Mesh |
mesh |
|
SubDividedCityObject.SubMesh |
subMesh |
|
Func<Vector3, Vector2> |
toVec2 |
|
System.Single |
epsilon |
|
Returns
Type |
Description |
List<Vector3> |
|
ComputeMeshOutlineVertices(UnityEngine.Mesh, Func<Vector3, Vector2>, Single)
Declaration
public static List<Vector3> ComputeMeshOutlineVertices(UnityEngine.Mesh mesh, Func<Vector3, Vector2> toVec2, float epsilon = 0.1F)
Parameters
Type |
Name |
Description |
UnityEngine.Mesh |
mesh |
|
Func<Vector3, Vector2> |
toVec2 |
|
System.Single |
epsilon |
|
Returns
Type |
Description |
List<Vector3> |
|
ComputeOutline<T>(IEnumerable<T>, Func<T, Vector3>, AxisPlane, Func<T, IEnumerable<T>>)
Declaration
public static GeoGraph2D.ComputeOutlineResult<T> ComputeOutline<T>(IEnumerable<T> vertices, Func<T, Vector3> toVec3, AxisPlane plane, Func<T, IEnumerable<T>> getNeighbor)
Parameters
Type |
Name |
Description |
IEnumerable<T> |
vertices |
|
Func<T, Vector3> |
toVec3 |
|
AxisPlane |
plane |
|
Func<T, IEnumerable<T>> |
getNeighbor |
|
Returns
Type Parameters
ComputeOutline2<T>(IEnumerable<T>, Func<T, Vector3>, AxisPlane, Func<T, IEnumerable<T>>)
Declaration
public static GeoGraph2D.ComputeOutlineResult<T> ComputeOutline2<T>(IEnumerable<T> vertices, Func<T, Vector3> toVec3, AxisPlane plane, Func<T, IEnumerable<T>> getNeighbor)
Parameters
Type |
Name |
Description |
IEnumerable<T> |
vertices |
|
Func<T, Vector3> |
toVec3 |
|
AxisPlane |
plane |
|
Func<T, IEnumerable<T>> |
getNeighbor |
|
Returns
Type Parameters
Contains(IEnumerable<Vector2>, Vector2)
verticesで表される多角形が点pを内包するかどうか
Declaration
public static bool Contains(IEnumerable<Vector2> vertices, Vector2 p)
Parameters
Type |
Name |
Description |
IEnumerable<Vector2> |
vertices |
|
Vector2 |
p |
|
Returns
Type |
Description |
System.Boolean |
|
pointsで表現された線分リストが自己交差している場合,その部分を削除する
4--5
| |
3------2
| |
6 1
↑の様な線分だと以下のようになる
3---2
| |
4 1
Declaration
public static List<List<T>> ExtractSelfCrossing<T>(IReadOnlyList<T> srcPoints, Func<T, Vector2> selector, GeoGraph2D.CreateSelfCrossingIntersectionPoint<T> creator, bool isLoop = false)
Parameters
Type |
Name |
Description |
IReadOnlyList<T> |
srcPoints |
|
Func<T, Vector2> |
selector |
|
GeoGraph2D.CreateSelfCrossingIntersectionPoint<T> |
creator |
交点に新しい点を作成する関数. p1-p2の線分, p3-p4の線分と交点intersection, (p1, p2, p3, p4, intersection, t1, t2) -> T
|
System.Boolean |
isLoop |
|
Returns
Type |
Description |
List<List<T>> |
|
Type Parameters
FindCollinearRange(Int32, IReadOnlyList<LineSegment2D>, Single, Nullable<Int32>, Nullable<Int32>)
edgesで定義された線分リストのedgeBaseIndex番の辺を基準に, 同一直線となる辺を探す.(許容誤差はtoleranceAngleDegForMidEdge)
Declaration
public static List<int> FindCollinearRange(int edgeBaseIndex, IReadOnlyList<LineSegment2D> edges, float toleranceAngleDegForMidEdge = 20F, int? startIndex = null, int? endIndex = null)
Parameters
Type |
Name |
Description |
System.Int32 |
edgeBaseIndex |
|
IReadOnlyList<LineSegment2D> |
edges |
|
System.Single |
toleranceAngleDegForMidEdge |
|
System.Nullable<System.Int32> |
startIndex |
|
System.Nullable<System.Int32> |
endIndex |
|
Returns
Type |
Description |
List<System.Int32> |
|
FindMidEdge(IReadOnlyList<Vector2>, Single, Single, GeoGraph2D.DebugFindOppositeOption)
verticesを始点終点から見ていき,お互い中心線を使って比較しながら中心の辺を表すインデックス配列を返す
Declaration
public static List<int> FindMidEdge(IReadOnlyList<Vector2> vertices, float toleranceAngleDegForMidEdge = 20F, float skipAngleDeg = 20F, GeoGraph2D.DebugFindOppositeOption op = null)
Parameters
Type |
Name |
Description |
IReadOnlyList<Vector2> |
vertices |
|
System.Single |
toleranceAngleDegForMidEdge |
中心線と同一直線と判断する線分の角度[deg]
|
System.Single |
skipAngleDeg |
開始線分との角度がこれ以下の間は絶対に中心線にならない
|
GeoGraph2D.DebugFindOppositeOption |
op |
|
Returns
Type |
Description |
List<System.Int32> |
|
FindTerminateEdgeIndex(IReadOnlyList<Vector2>)
verticesを始点終点から見ていき, 中間地点となる辺を表すインデックスを返す
vertices[index], vertices[index + 1]が中間地点となる
Declaration
public static int FindTerminateEdgeIndex(IReadOnlyList<Vector2> vertices)
Parameters
Type |
Name |
Description |
IReadOnlyList<Vector2> |
vertices |
|
Returns
Type |
Description |
System.Int32 |
|
GetBorderParabola(Ray2D, Vector2, Single)
vと直線rayをp : 1-pで分割する放物線を返す
Declaration
public static GeoGraph2D.BorderParabola2D GetBorderParabola(Ray2D ray, Vector2 v, float p)
Parameters
Type |
Name |
Description |
Ray2D |
ray |
|
Vector2 |
v |
|
System.Single |
p |
|
Returns
GetInnerLerpSegments(IReadOnlyList<Vector2>, IReadOnlyList<Vector2>, Single, GeoGraph2D.DebugOption)
selfの左右の道を横幅p : (1-p)で分割した線分を返す. p=[0,1]
例) 0.5だと中央線が返る, 0だとLeftが返る, 1だとRightが返る.
Declaration
public static List<GeoGraph2D.InnerSegment> GetInnerLerpSegments(IReadOnlyList<Vector2> seg0, IReadOnlyList<Vector2> seg1, float p, GeoGraph2D.DebugOption op = null)
Parameters
Type |
Name |
Description |
IReadOnlyList<Vector2> |
seg0 |
|
IReadOnlyList<Vector2> |
seg1 |
|
System.Single |
p |
|
GeoGraph2D.DebugOption |
op |
|
Returns
GetNearVertexTable(IList<Vector3>, Func<Vector3, Vector3, Single>, Single)
点群vertices, 互いの距離がepsilon以下の頂点をリンクさせた辞書が返る
辞書にない頂点は近い頂点が無いもの
key : 元の頂点, value : 近い頂点のうち最初に見つかったもの
Declaration
public static int[] GetNearVertexTable(IList<Vector3> vertices, Func<Vector3, Vector3, float> calcDistance, float epsilon = 0.1F)
Parameters
Type |
Name |
Description |
IList<Vector3> |
vertices |
|
Func<Vector3, Vector3, System.Single> |
calcDistance |
|
System.Single |
epsilon |
|
Returns
Type |
Description |
System.Int32[] |
|
IsClockwise(IEnumerable<Vector2>)
ポリゴンを構成する頂点配列を渡すと, そのポリゴンが時計回りなのか反時計回りなのかを返す
Declaration
public static bool IsClockwise(IEnumerable<Vector2> vertices)
Parameters
Type |
Name |
Description |
IEnumerable<Vector2> |
vertices |
|
Returns
Type |
Description |
System.Boolean |
|
IsInsidePolygon(Vector2, IList<Vector2>)
pointがverticesで構成される多角形の内部にあるかどうかを返す.
Declaration
public static bool IsInsidePolygon(Vector2 point, IList<Vector2> vertices)
Parameters
Type |
Name |
Description |
Vector2 |
point |
|
IList<Vector2> |
vertices |
|
Returns
Type |
Description |
System.Boolean |
|
LerpRay(Ray2D, Ray2D, Single)
直線l上の点から直線a,bへの距離がp : 1-pとなるような直線lを返す
0.5だと中間の角度が返る
\ p |1-p /
\ | /
\ | /
a \ | / b
\ /
Declaration
public static Ray2D LerpRay(Ray2D rayA, Ray2D rayB, float p)
Parameters
Type |
Name |
Description |
Ray2D |
rayA |
|
Ray2D |
rayB |
|
System.Single |
p |
|
Returns
LerpRay2(Ray2D, Ray2D, Single)
直線l上の点から直線a,bへの距離がp : 1-pとなるような直線lを返す
0.5だと中間の角度が返る
\ p |1-p /
\ | /
\ | /
a \ | / b
\ /
Declaration
public static Ray2D LerpRay2(Ray2D rayA, Ray2D rayB, float p)
Parameters
Type |
Name |
Description |
Ray2D |
rayA |
|
Ray2D |
rayB |
|
System.Single |
p |
|
Returns
PolygonHalfLineIntersection(IEnumerable<Vector2>, Ray2D, out Vector2, out Single, Boolean)
頂点verticesで構成されるポリゴン(isLoop = falseの時は開いている)と半直線rayとの交点を返す
Declaration
public static bool PolygonHalfLineIntersection(IEnumerable<Vector2> vertices, Ray2D ray, out Vector2 intersection, out float t, bool isLoop = true)
Parameters
Type |
Name |
Description |
IEnumerable<Vector2> |
vertices |
|
Ray2D |
ray |
|
Vector2 |
intersection |
|
System.Single |
t |
|
System.Boolean |
isLoop |
|
Returns
Type |
Description |
System.Boolean |
|
PolygonHalfLineIntersectionXZ(IEnumerable<Vector3>, Ray, out Vector3, out Single, Boolean)
頂点verticesで構成されるポリゴン(isLoop = falseの時は開いている)と半直線rayとの交点を返す.
ただし、y座標は無視してXz平面だけで当たり判定を行う
Declaration
public static bool PolygonHalfLineIntersectionXZ(IEnumerable<Vector3> vertices, Ray ray, out Vector3 intersection, out float t, bool isLoop = true)
Parameters
Type |
Name |
Description |
IEnumerable<Vector3> |
vertices |
|
Ray |
ray |
|
Vector3 |
intersection |
|
System.Single |
t |
|
System.Boolean |
isLoop |
|
Returns
Type |
Description |
System.Boolean |
|
PolygonSegmentIntersection(IEnumerable<Vector2>, Vector2, Vector2, out Vector2, out Single, Boolean)
頂点verticesで構成されるポリゴン(isLoop = falseの時は開いている)と半直線rayとの交点を返す
Declaration
public static bool PolygonSegmentIntersection(IEnumerable<Vector2> vertices, Vector2 st, Vector2 en, out Vector2 intersection, out float t, bool isLoop = true)
Parameters
Type |
Name |
Description |
IEnumerable<Vector2> |
vertices |
|
Vector2 |
st |
|
Vector2 |
en |
|
Vector2 |
intersection |
|
System.Single |
t |
|
System.Boolean |
isLoop |
|
Returns
Type |
Description |
System.Boolean |
|
PolygonSegmentIntersectionXZ(IEnumerable<Vector3>, Vector3, Vector3, out Vector3, out Single, Boolean)
頂点verticesで構成されるポリゴン(isLoop = falseの時は開いている)と半直線rayとの交点を返す.
ただし、y座標は無視してXz平面だけで当たり判定を行う
Declaration
public static bool PolygonSegmentIntersectionXZ(IEnumerable<Vector3> vertices, Vector3 st, Vector3 en, out Vector3 intersection, out float t, bool isLoop = true)
Parameters
Type |
Name |
Description |
IEnumerable<Vector3> |
vertices |
|
Vector3 |
st |
|
Vector3 |
en |
|
Vector3 |
intersection |
|
System.Single |
t |
|
System.Boolean |
isLoop |
|
Returns
Type |
Description |
System.Boolean |
|
RemoveSelfCrossing<T>(List<T>, Func<T, Vector2>, GeoGraph2D.CreateSelfCrossingIntersectionPoint<T>)
pointsで表現された線分リストが自己交差している場合,その部分を削除する
4--5
| |
3------2
| |
6 1
↑の様な線分だと以下のようになる
3---2
| |
4 1
Declaration
public static void RemoveSelfCrossing<T>(List<T> points, Func<T, Vector2> selector, GeoGraph2D.CreateSelfCrossingIntersectionPoint<T> creator)
Parameters
Type Parameters
SplitByCollinearSegment(IReadOnlyList<Vector2>, Single, Single, Boolean)
verticesで表される線分を, toleranceAngleDeg/midPointToleranceを使った同一直線判定でグルーピングする
戻り値はグループの始点インデックス
例) (v0, v1, v2, v3, v4, v5)
v0~v1, v1~v5が同一直線なら[0, 2, 5]が返る
v0~v5が同一直線なら[0, 5]が返る
Declaration
public static List<int> SplitByCollinearSegment(IReadOnlyList<Vector2> vertices, float toleranceAngleDeg = 0F, float midPointTolerance = 0F, bool checkAdjustSegmentAngleOnly = false)
Parameters
Type |
Name |
Description |
IReadOnlyList<Vector2> |
vertices |
|
System.Single |
toleranceAngleDeg |
|
System.Single |
midPointTolerance |
|
System.Boolean |
checkAdjustSegmentAngleOnly |
|
Returns
Type |
Description |
List<System.Int32> |
|
TryFindMidEdge2(IReadOnlyList<Vector2>, out Int32, out Int32, Single, Single, GeoGraph2D.DebugFindOppositeOption)
verticesを始点終点から見ていき,中央を表す頂点のインデックスを返す
Declaration
public static bool TryFindMidEdge2(IReadOnlyList<Vector2> vertices, out int edgeStartIndex, out int edgeEndIndex, float toleranceAngleDegForMidEdge = 20F, float skipAngleDeg = 20F, GeoGraph2D.DebugFindOppositeOption op = null)
Parameters
Type |
Name |
Description |
IReadOnlyList<Vector2> |
vertices |
|
System.Int32 |
edgeStartIndex |
中央線分の開始インデックス
|
System.Int32 |
edgeEndIndex |
中央線分の終了インデックス
|
System.Single |
toleranceAngleDegForMidEdge |
中心線と同一直線と判断する線分の角度[deg]
|
System.Single |
skipAngleDeg |
開始線分との角度がこれ以下の間は絶対に中心線にならない
|
GeoGraph2D.DebugFindOppositeOption |
op |
|
Returns
Type |
Description |
System.Boolean |
|