Skip to content

Commit

Permalink
small utils
Browse files Browse the repository at this point in the history
  • Loading branch information
rms80 committed Mar 29, 2018
1 parent 8370d23 commit fd44fe9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
8 changes: 7 additions & 1 deletion math/BoundsUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ public static AxisAlignedBox3d Bounds(ref Vector3d v0, ref Vector3d v1, ref Vect
return box;
}


public static AxisAlignedBox2d Bounds(ref Vector2d v0, ref Vector2d v1, ref Vector2d v2)
{
AxisAlignedBox2d box;
MathUtil.MinMax(v0.x, v1.x, v2.x, out box.Min.x, out box.Max.x);
MathUtil.MinMax(v0.y, v1.y, v2.y, out box.Min.y, out box.Max.y);
return box;
}

// AABB of transformed AABB (corners)
public static AxisAlignedBox3d Bounds(ref AxisAlignedBox3d boxIn, Func<Vector3d,Vector3d> TransformF)
Expand Down
17 changes: 17 additions & 0 deletions math/IndexUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,23 @@ public static void Apply(int[] indices, IList<int> map)
indices[i] = map[indices[i]];
}




public static void TrianglesToVertices(DMesh3 mesh, HashSet<int> triangles, HashSet<int> vertices) {
foreach ( int tid in triangles ) {
Index3i tv = mesh.GetTriangle(tid);
vertices.Add(tv.a); vertices.Add(tv.b); vertices.Add(tv.c);
}
}

public static void TrianglesToEdges(DMesh3 mesh, HashSet<int> triangles, HashSet<int> edges) {
foreach ( int tid in triangles ) {
Index3i te = mesh.GetTriEdges(tid);
edges.Add(te.a); edges.Add(te.b); edges.Add(te.c);
}
}

}


Expand Down
2 changes: 1 addition & 1 deletion queries/MeshQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static DistPoint3Triangle3 TriangleDistance(DMesh3 mesh, int ti, Vector3d
}

/// <summary>
/// Find point-normal frame at closest point to queryPoint on mesh.
/// Find point-normal(Z) frame at closest point to queryPoint on mesh.
/// Returns interpolated vertex-normal frame if available, otherwise tri-normal frame.
/// </summary>
public static Frame3f NearestPointFrame(DMesh3 mesh, ISpatial spatial, Vector3d queryPoint)
Expand Down

0 comments on commit fd44fe9

Please sign in to comment.