Skip to content

Commit

Permalink
Merge branch 'release/0.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanRynne committed Nov 21, 2020
2 parents 5cfceb6 + 31dd0b0 commit 2bb9cb5
Show file tree
Hide file tree
Showing 119 changed files with 4,240 additions and 2,488 deletions.
518 changes: 116 additions & 402 deletions .editorconfig

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## [0.1.0] - 21-Nov-2020

So... another couple of release notes missing! 😅 What's important?

- Added NURBS support in curves and surfaces.
- Added some spatial search algorithms.
- Improved testing and coverage.

## [0.0.6] - 14-June-2020

Expand Down
10 changes: 9 additions & 1 deletion Paramdigma.Core.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Binormal/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Circumcenter/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=circumcircle/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Delaunay/@EntryIndexedValue">True</s:Boolean>


<s:Boolean x:Key="/Default/UserDictionary/Words/=Paramdigma/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Perp/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Perp/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Voronoi/@EntryIndexedValue">True</s:Boolean>

</wpf:ResourceDictionary>
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
[![License](https://img.shields.io/github/license/Paramdigma/Core.svg)](https://github.com/Paramdigma/Core/blob/master/LICENSE)

![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/paramdigma/core?sort=semver)
![GitHub commits since latest release (by SemVer)](https://img.shields.io/github/commits-since/paramdigma/core/latest/master?sort=semver)
![Main language](https://img.shields.io/github/languages/top/Paramdigma/Core.svg)
![Code Size](https://img.shields.io/github/languages/code-size/Paramdigma/Core.svg)

Expand Down Expand Up @@ -37,7 +36,7 @@ If you are looking for just a geometry library to plug into a project we also pr
## Documentation

You can find the Docfx built documentation for the latest relase on the 'master' branch at:
You can find the Docfx built documentation for the latest release on the 'master' branch at:

[https://paramdigma.com/Core/](https://paramdigma.com/Core/)

Expand Down
27 changes: 15 additions & 12 deletions src/Collections/Interval.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public Interval(double start, double end)
this.End = end;
}


/// <summary>
/// Initializes a new instance of the <see cref="Interval" /> struct from another interval.
/// </summary>
Expand All @@ -30,6 +31,7 @@ public Interval(double start, double end)
public Interval(Interval interval)
: this(interval.Start, interval.End) { }


/// <summary>
/// Gets a new unit interval.
/// </summary>
Expand All @@ -40,21 +42,13 @@ public Interval(Interval interval)
/// Gets or sets the starting value of the interval.
/// </summary>
/// <value>Value will always be lower unless interval is inverted.</value>
public double Start
{
get;
set;
}
public double Start { get; set; }

/// <summary>
/// Gets or sets the ending value of the interval.
/// </summary>
/// <value>Value will always be the biggest unless interval is inverted.</value>
public double End
{
get;
set;
}
public double End { get; set; }

/// <summary>
/// Gets the space between the start and end of the interval.
Expand All @@ -66,6 +60,7 @@ public double End
/// </summary>
public bool HasInvertedDirection => this.Length < 0;


/// <summary>
/// Crop a number so that it's contained on the given interval.
/// </summary>
Expand All @@ -81,6 +76,7 @@ public static double CropNumber(double number, Interval interval)
return number;
}


/// <summary>
/// Remap a number from one interval to another.
/// </summary>
Expand All @@ -93,23 +89,27 @@ public static double RemapNumber(double number, Interval fromInterval, Interval
var cropped = fromInterval.Contains(number) ? number : fromInterval.Crop(number);
var proportion = (cropped - fromInterval.Start) / Math.Abs(fromInterval.Length);

return toInterval.Start + (toInterval.Length * proportion);
return toInterval.Start + toInterval.Length * proportion;
}


/// <summary>
/// Crop a number so that it is contained inside this interval.
/// </summary>
/// <param name="number">Number to crop.</param>
/// <returns>Cropped number.</returns>
public double Crop(double number) => CropNumber(number, this);


/// <summary>
/// Remap a number from this interval to a given one.
/// </summary>
/// <param name="number">Number to remap.</param>
/// <param name="toInterval">Interval to remap number to.</param>
/// <returns>Remapped number inside given interval.</returns>
public double Remap(double number, Interval toInterval) => RemapNumber(number, this, toInterval);
public double Remap(double number, Interval toInterval) =>
RemapNumber(number, this, toInterval);


/// <summary>
/// Remap a number from this interval to a unit interval.
Expand All @@ -118,13 +118,15 @@ public static double RemapNumber(double number, Interval fromInterval, Interval
/// <returns>Value remaped from 0 to 1.</returns>
public double RemapToUnit(double number) => this.Remap(number, Unit);


/// <summary>
/// Remap a number from a unit interval to this interval.
/// </summary>
/// <param name="number">Number to remap.</param>
/// <returns>Remapped number.</returns>
public double RemapFromUnit(double number) => Unit.Remap(number, this);


/// <summary>
/// Check if a number is contained inside this interval.
/// </summary>
Expand All @@ -137,6 +139,7 @@ public bool Contains(double number)
return min <= number && number <= max;
}


/// <summary>
/// Swap the Start and End values of this interval.
/// </summary>
Expand Down
45 changes: 37 additions & 8 deletions src/Collections/Matrix{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,40 @@ public class Matrix<T>
// https://codereview.stackexchange.com/questions/194732/class-matrix-implementation
private T[,] data;


/// <summary>
/// Initializes a new instance of the <see cref="Matrix{T}" /> class.
/// </summary>
/// <param name="n">Size of the square Matrix.</param>
public Matrix(int n) => this.data = new T[n, n];


/// <summary>
/// Initializes a new instance of the <see cref="Matrix{T}" /> class of the specified size.
/// </summary>
/// <param name="n">Column size.</param>
/// <param name="m">Row size.</param>
public Matrix(int n, int m) => this.data = new T[n, m];


/// <summary>
/// Initializes a new instance of the <see cref="Matrix{T}" /> class from a 2D array.
/// </summary>
/// <param name="data">2D array of data.</param>
public Matrix(T[,] data) => this.data = data;


/// <summary>
/// Gets columns.
/// </summary>
/// <returns>Number of columns on the Matrix.</returns>
public int N => this.data.GetUpperBound(0) + 1;
public int N => this.data.GetLength(0);

/// <summary>
/// Gets rows.
/// </summary>
/// <returns>Number of rows on the Matrix.</returns>
public int M => this.data.GetUpperBound(1) + 1;
public int M => this.data.GetLength(1);

/// <summary>
/// Gets a specific item in the matrix.
Expand All @@ -52,6 +56,12 @@ public class Matrix<T>
/// <param name="column">Column.</param>
public ref T this[int row, int column] => ref this.data[row, column];

/// <summary>
/// Gets the amount of items in this matrix.
/// </summary>
public int Count => this.data.Length;


/// <summary>
/// Get the row of a matrix at the specified index.
/// </summary>
Expand All @@ -66,6 +76,7 @@ public T[] Row(int n)
return row;
}


/// <summary>
/// Get the column of a matrix at the specified index.
/// </summary>
Expand All @@ -80,34 +91,47 @@ public T[] Column(int m)
return col;
}


// ----- ORDERING METHODS -----


/// <summary>
/// Turns columns into rows and rows into columns.
/// </summary>
public void FlipMatrix() => throw
// TODO: Implement FlipMatrix()
new NotImplementedException();
// TODO: Implement FlipMatrix()
new NotImplementedException();


/// <summary>
/// Increment Matrix column size by a specified amount.
/// It accepts both increasing and decreasing the size.
/// </summary>
/// <param name="incrementN">Positive or negative increment.</param>
public void IncrementColumns(int incrementN) => this.ResizeMatrix(ref this.data, this.N + incrementN, this.M);
public void IncrementColumns(int incrementN) => this.ResizeMatrix(
ref this.data,
this.N + incrementN,
this.M);


/// <summary>
/// Increment Matrix row size by a specified amount.
/// It accepts both increasing and decreasing the size.
/// </summary>
/// <param name="incrementM">Positive or negative increment.</param>
public void IncrementRows(int incrementM) => this.ResizeMatrix(ref this.data, this.N, this.M + incrementM);
public void IncrementRows(int incrementM) => this.ResizeMatrix(
ref this.data,
this.N,
this.M + incrementM);


/// <summary>
/// Increase or decrease the matrix size symetrically.
/// </summary>
/// <param name="symetricIncrement">Symetric increase/decrease.</param>
public void IncrementMatrixSize(int symetricIncrement) => this.IncrementMatrixSize(symetricIncrement, symetricIncrement);
public void IncrementMatrixSize(int symetricIncrement) =>
this.IncrementMatrixSize(symetricIncrement, symetricIncrement);


/// <summary>
/// Increase or decrease the column size of the matrix.
Expand All @@ -120,6 +144,7 @@ public void IncrementMatrixSize(int columnIncrement, int rowIncrement)
this.IncrementRows(rowIncrement);
}


/// <summary>
/// Obtains all neighbour entities surrounding the specified matrix coordinates.
/// </summary>
Expand All @@ -135,6 +160,7 @@ public List<T> GetAllNeighboursAt(int column, int row)
return neighbours;
}


/// <summary>
/// Obtains corner neighbour entities surrounding the specified matrix coordinates.
/// </summary>
Expand All @@ -145,6 +171,7 @@ public List<T> GetAllNeighboursAt(int column, int row)
// TODO: Implement GetCornerNeighboursOfEntityAt()
new NotImplementedException();


/// <summary>
/// Obtains contiguous neighbour entities surrounding the specified matrix coordinates.
/// </summary>
Expand All @@ -155,10 +182,12 @@ public List<T> GetAllNeighboursAt(int column, int row)
// TODO: Implement GetContiguousNeighboursOfEntityAt()
new NotImplementedException();


/// <summary>
/// Resizes any given 2 dimensional array.
/// It accepts smaller and bigger array outputs.
/// Obtained from: https://stackoverflow.com/questions/6539571/how-to-resize-multidimensional-2d-array-in-c .
/// Obtained from:
/// https://stackoverflow.com/questions/6539571/how-to-resize-multidimensional-2d-array-in-c .
/// </summary>
/// <param name="original">2D Array to resize.</param>
/// <param name="newCoNum">Number of resulting columns in the array.</param>
Expand Down
15 changes: 12 additions & 3 deletions src/Curves/Geodesics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ public static class Geodesics
/// <param name="maxIter">Maximum iterations.</param>
/// <param name="geodesic">Geodesic curves.</param>
/// <returns>True if successful.</returns>
public static bool StartDir(MeshPoint meshPoint, Vector3d vector, Mesh mesh, int maxIter, out List<Point3d> geodesic)
public static bool StartDir(
MeshPoint meshPoint,
Vector3d vector,
Mesh mesh,
int maxIter,
out List<Point3d> geodesic)
{
// Get initial face on the mesh
var initialFace = mesh.Faces[meshPoint.FaceIndex];
Expand Down Expand Up @@ -48,8 +53,12 @@ public static bool StartDir(MeshPoint meshPoint, Vector3d vector, Mesh mesh, int
var nextFace = halfEdge.Twin.Face;

// Flip vector to next face
var perpVector = Vector3d.CrossProduct(thisDirection, MeshGeometry.FaceNormal(thisFace));
var nextVector = Vector3d.CrossProduct(MeshGeometry.FaceNormal(nextFace), perpVector);
var perpVector = Vector3d.CrossProduct(
thisDirection,
MeshGeometry.FaceNormal(thisFace));
var nextVector = Vector3d.CrossProduct(
MeshGeometry.FaceNormal(nextFace),
perpVector);

// Assign iteration variables to current
thisPoint = nextPoint;
Expand Down
Loading

0 comments on commit 2bb9cb5

Please sign in to comment.