forked from gradientspace/geometry3Sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
a bunch of useful functions, Box3 containment, some useful iterator c…
…lasses. no functionality changes.
- Loading branch information
Showing
9 changed files
with
292 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace g3 | ||
{ | ||
|
||
// ported from GTEngine GteContOrientedBox3.h | ||
// (2017) url: https://www.geometrictools.com/GTEngine/Include/Mathematics/GteContOrientedBox3.h | ||
public class ContOrientedBox3 | ||
{ | ||
public Box3d Box; | ||
public bool ResultValid = false; | ||
|
||
public ContOrientedBox3(IEnumerable<Vector3d> points) | ||
{ | ||
// Fit the points with a Gaussian distribution. | ||
GaussPointsFit3 fitter = new GaussPointsFit3(points); | ||
if (fitter.ResultValid == false) | ||
return; | ||
this.Box = fitter.Box; | ||
this.Box.Contain(points); | ||
} | ||
|
||
public ContOrientedBox3(IEnumerable<Vector3d> points, IEnumerable<double> pointWeights) | ||
{ | ||
// Fit the points with a Gaussian distribution. | ||
GaussPointsFit3 fitter = new GaussPointsFit3(points, pointWeights); | ||
if (fitter.ResultValid == false) | ||
return; | ||
this.Box = fitter.Box; | ||
this.Box.Contain(points); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
|
||
namespace g3 | ||
{ | ||
/* | ||
* Utility generic iterators | ||
*/ | ||
|
||
/// <summary> | ||
/// Iterator that just returns a constant value N times | ||
/// </summary> | ||
public class ConstantItr<T> : IEnumerable<T> | ||
{ | ||
public T ConstantValue = default(T); | ||
public int N; | ||
|
||
public ConstantItr(int count, T constant) { | ||
N = count; ConstantValue = constant; | ||
} | ||
public IEnumerator<T> GetEnumerator() { | ||
for (int i = 0; i < N; ++i) | ||
yield return ConstantValue; | ||
} | ||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Iterator that re-maps iterated values via a Func | ||
/// </summary> | ||
public class RemapItr<T,T2> : IEnumerable<T> | ||
{ | ||
public IEnumerable<T2> OtherItr; | ||
public Func<T2, T> ValueF; | ||
|
||
public RemapItr(IEnumerable<T2> otherIterator, Func<T2,T> valueFunction) | ||
{ | ||
OtherItr = otherIterator; ValueF = valueFunction; | ||
} | ||
public IEnumerator<T> GetEnumerator() { | ||
foreach (T2 idx in OtherItr) | ||
yield return ValueF(idx); | ||
} | ||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters