Projects Issues Blogs Broadcasts Groups Events Resources
Project

GeometRi

Simple and lightweight computational geometry library for .Net

GeometRi

Simple and lightweight computational geometry library for .Net

This version is obsolete. Please use C# version of the library: GeometRi.CSharp

GeomtRi is a simple and lightweight 3D geometry library for .Net. It is not one more 3D graphics library, its main job is manipulations with basic geometrical primitives, such as point, line, plane, segment in 3D space: translation and rotation operations, distance calculation, intersections, orthogonal projections of one object into another, etc. The objects can be defined in global or in one of the local coordinate systems and converted form one coordinate system into another.

The library was build to be as simple and intuitive as posible. Users do not have to remember the reference coordinate system of each object. The objects store the coordinate system they are defined in and all transformations will be caried out implicitly when necessary.

The main goal was simplisity and readability of the code, therefore speed and robustness was not a priority. Global tolerance property is used for proximity checking, not an exact robust algorithms.

Installation

Use NuGet to install library. Search for GeometRi in NuGet package manager or type in the Package Manager Console:

Install-Package GeometRi

Classes

  • Point3d and Vector3d are two base classes, representing points and vectors in 3D space. Objects of type Point3d or Vector3d can be defined in global or in local coordinate systems.

  • Line3d, Ray3d, Segment3d, Plane3d, Circle3d, Sphere, Ellipse and Triangle are compound classes, which are defined in terms of points and vectors.

  • Coord3d and Matrix3d are auxiliary classes.

  • GeometRi3d is an abstract class, which defines some common functionality, for example global tolerance property (GeometRi3d.Tolerance) used in proximity operations by other classes. Implements tolerance based equality methods: AlmostEqual(double, double), NotEqual(double,double), Greater(double, double) and Smaller(double, double).

Point3d

One of the base classes, can be constructed by three double numbers (X, Y and Z) or from double array. Each constructor has optional parameter 'coord' for local coordinate system in which point will be defined. By default all points are defined in global coordinate system.

Properties

  • X - X coordinate in reference coordinate system
  • Y - Y coordinate in reference coordinate system
  • Z - Z coordinate in reference coordinate system
  • Coord - reference coordinate system
  • ToVector - radius vector of point

Methods

  • Clone - deep copy of object
  • ConvertTo - convert point to local coordinate system
  • ConvertToGlobal - convert point to global coordinate system
  • Add - add two points
  • Subtract - subtract one point from other
  • Scale - scale point by given number
  • DistanceTo - shortest distance from point to point, line, plane, ray or segment
  • ProjectionTo - orthogonal projection of point to line, plane or sphere
  • BelongsTo - check if point belongs to line, ray, segment, plane, circle, ellipse or sphere surface
  • IsInside - check if point is inside circle or sphere
  • Translate - translate point by vector
  • Rotate - rotate point around origin or other point
  • Reflect - reflect point in point, line or plane
  • Equals - check if two points are equals
  • ToString - string representation of point in global or local coordinate system

Static methods

  • CollinearPoints - check if three points are collinear

Overloaded operators

  • + - add two points
  • - - subtract one point from other
  • - - unary operator
  • * - scale point by number
  • / - scale point by number
  • = - equality check
  • <> - unequality check

Vector3d

Second base class, representing vector in 3D space. Constructed by three components (X, Y and Z) or from double array (with optional 'coord' parameter for local cordinate system). Additionally, can be constructed by point, representing radius vector of that point, or by two points, representing vector from first point to another. In this cases the vector will be defined in the same coordinate system as the first operand.

Properties

  • X - X component in reference coordinate system
  • Y - Y component in reference coordinate system
  • Z - Z component in reference coordinate system
  • Coord - reference coordinate system
  • Norm - Norm of a vector
  • ToPoint - point, represented by vector starting in origin
  • OrthogonalVector - return arbitrary vector, orthogonal to the current vector

Methods

  • Clone - deep copy of object
  • ConvertTo - convert vector to local coordinate system
  • ConvertToGlobal - convert vector to global coordinate system
  • Normalize - normalize the current vector
  • Normalized - return normalized vector
  • IsParallelTo - check if two vectors are parallel
  • IsNotParallelTo - check if two vectors are NOT parallel
  • IsOrthogonalTo - check if two vectors are orthogonal
  • Add - overloaded, add number or vector
  • Subtract - oveloaded, subtract number or vector
  • Mult - overloaded, multiply by number or vector
  • Dot - dot product of two vectors
  • AngleTo - angle between vector and other vector, line, plane, ray or segment
  • AngleToDeg - angle between vector and other vector, line, plane, ray or segment (in degrees)
  • ProjectionTo - return projection of the current vector to the second vector
  • Rotate - rotate vector around origin
  • Reflect - reflect vector in point, line or plane
  • Equals - check if two vectors are equals
  • ToString - string representation of vector in global or local coordinate system

Line3d

Represent infinite line in 3D space and is defined by any point lying on the line and a direction vector.

Properties

  • Point - base point of the line
  • Direction - direction vector of the line

Methods

  • Clone - deep copy of object
  • DistanceTo - shortest distance to point, line, ray or segment
  • PerpendicularTo - point on the perpendicular to the second line
  • IntersectionWith - intersection of line with plane or sphere
  • ProjectionTo - orthogonal projection of a line to the plane
  • AngleTo - angle between line and other line or plane
  • AngleToDeg - angle between line and other line or plane (in degrees)
  • Translate - translate line by vector
  • Rotate - rotate line around origin or other point
  • Reflect - reflect line in point, line or plane
  • Equals - check if two lines are equals
  • ToString - string representation of line in global or local coordinate system

Ray3d

Represent ray in 3D space and is defined by starting point and direction vector.

Properties

  • Point - base point of the ray
  • Direction - direction vector of the ray
  • ToLine - convert ray to line

Methods

  • Clone - deep copy of object
  • DistanceTo - shortest distance to point, line, segment or other ray
  • PerpendicularTo - point on the perpendicular to the line
  • IntersectionWith - intersection of ray with plane
  • ProjectionTo - orthogonal projection of ray to the plane
  • AngleTo - angle between ray and plane
  • AngleToDeg - angle between ray and plane (in degrees)
  • Translate - translate ray by vector
  • Rotate - rotate ray around origin or other point
  • Reflect - reflect ray in point, line or plane
  • Equals - check if two rays are equals
  • ToString - string representation of ray in global or local coordinate system

Segment3d

Represent a line segment in 3D space and is defined by two points.

Properties

  • P1 - first point of the segment
  • P2 - second point of the segment
  • Length - length of the segment
  • ToVector - convert segment to vector
  • ToRay - convert segment to ray
  • ToLine - convert segment to line

Methods

  • Clone - deep copy of object
  • DistanceTo - shortest distance to point, line, ray, plane or other segment
  • IntersectionWith - intersection of segment with plane
  • ProjectionTo - orthogonal projection of segment to the line or plane
  • AngleTo - angle between segment and plane
  • AngleToDeg - angle between segment and plane (in degrees)
  • Translate - translate segment by vector
  • Rotate - rotate segment around origin or other point
  • Reflect - reflect segment in point, line or plane
  • Equals - check if two segments are equals
  • ToString - string representation of serment in global or local coordinate system

Plane3d

Defined by arbutrary point on the plane and a normal vector. Optionally can be defined by coefficients in general equation of plane (Ax + By + Cz + D = 0), by three points or by point and two vectors in the plane.

Properties

  • Point - point on the plane
  • Normal - normal vector of the plane
  • A/B/C/D - coefficients A, B, C and D in the general plane equation

Methods

  • Clone - deep copy of object
  • SetCoord - set reference coordinate system for general plane equation
  • IntersectionWith - intersection of plane with line, plane, sphere, circle or two other planes
  • AngleTo - angle between plane and vector, line or plane
  • AngleToDeg - angle between plane and vector, line or plane (in degrees)
  • Translate - translate plane by vector
  • Rotate - rotate plane around origin or other point
  • Reflect - reflect plane in point, line or plane
  • Equals - check if two planes are equals
  • ToString - string representation of plane in global or local coordinate system

Sphere

Defines a sphere in 3D space. Implements intersection with line, plane and other sphere, projection to line and plane, as well as common translation, rotation and reflection methods.

Properties

  • Center - center of the sphere
  • R - radius of the sphere
  • Area - area of the sphere
  • Volume - volume of the sphere

Methods

  • Clone - deep copy of object
  • DistanceTo - shortest distance to point, line, ray, segment or plane
  • IntersectionWith - intersection of sphere with line, plane or other sphere
  • ProjectionTo - orthogonal projection of sphere to the line or plane
  • Translate - translate sphere by vector
  • Rotate - rotate sphere around origin or other point
  • Reflect - reflect sphere in point, line or plane
  • Equals - check if two spheres are equals
  • ToString - string representation of sphere in global or local coordinate system

Circle3d

Defines a circle in 3D space. Implements common translation, rotation and reflection methods.

Properties

  • Center - center of the circle
  • R - radius of the circle
  • Normal - normal of the circle
  • Perimeter - perimeter of the circle
  • Area - area of the circle
  • ToEllipse - convert circle to equivalent ellipse

Methods

  • Clone - deep copy of object
  • ParametricForm - return point on circle for given parameter 't'
  • ProjectionTo - orthogonal projection of circle to plane
  • IntersectionWith - intersection of circle with plane
  • Translate - translate circle by vector
  • Rotate - rotate circle around origin or other point
  • Reflect - reflect circle in point, line or plane
  • Equals - check if two circles are equals
  • ToString - string representation of circle in global or local coordinate system

Ellipse

Defines an ellipse in 3D space, represented by center point and two vectors, for major and minor semiaxes.

Properties

  • Center - center of the ellipse
  • MajorSemiaxis - major semiaxis of the ellipse
  • MinorSemiaxis - minor semiaxis of the ellipse
  • Normal - normal of the ellipse
  • A - length of major semiaxis
  • B - length of minor semiaxis
  • F - distance from center to focus
  • F1 - first focus
  • F2 - second focus
  • e - eccentricity of the ellipse
  • Perimeter - approximate circumference of the ellipse
  • Area - area of the ellipse

Methods

  • Clone - deep copy of object
  • ParametricForm - return point on ellipse for given parameter 't'
  • ProjectionTo - orthogonal projection of ellipse to plane
  • Translate - translate ellipse by vector
  • Rotate - rotate ellipse around origin or other point
  • Reflect - reflect ellipse in point, line or plane
  • Equals - check if two ellipses are equals
  • ToString - string representation of ellipse in global or local coordinate system

Triangle

Defines a triangle n 3D space. Implements common translation, rotation and reflection methods. Calculates most of the standard triangle properties: bisectors, meadians, altitudes, incenter, circumcenter, centroid, orthocenter, etc.

Properties

  • A/B/C - vertices of the triangle
  • AB/AC/BC - length of the triangles' sides
  • Perimeter - perimeter of the triangle
  • Area - area of the triangle
  • Circumcircle - circumcircle of the triangle
  • Angle_A/B/C - angle at the vertex A/B/C
  • Bisector_A/B/C - angle bisector at the vertex A/B/C
  • Incenter - incenter of the triangle
  • Centroid - centroid of the triangle
  • Orthocenter - orthocenter of the triangle
  • Circumcenter - circumcenter of the triangle
  • Incircle - incircle of the triangle
  • Altitude_A/B/C - altitude at the vertex A/B/C
  • Median_A/B/C - median at the vertex A/B/C
  • IsEquilateral - check if all sides of the triangle are the same length
  • IsIsosceles - check if two sides of the triangle are the same length
  • IsScalene - check if all sides are unequal
  • IsRight - check if one angle is equal 90 degrees
  • IsObtuse - check if one angle is greater than 90 degrees
  • IsAcute - check if all angles are less than 90 degrees

Methods

  • Clone - deep copy of object
  • Translate - translate triangle by vector
  • Rotate - rotate triangle around origin or other point
  • Reflect - reflect triangle in point, line or plane
  • Equals - check if two triangles are equals
  • ToString - string representation of triangle in global or local coordinate system

Coord3d

Class representing orthogonal cartesian 3D coordinate system. Defined by an origin point and transformation matrix (three orthogonal unit vectors stored in row format). One global coordinate system (Coord3d.GlobalCS) is defined by default, any number of local coordinate systems can be defined by users.

Properties

  • Origin - origin of the coordinate system
  • Axes - unit vectors of the axes, stored as row-matrix(3x3)
  • Name - name of the coordinate system
  • Counts - total number of defined coordinate systems
  • X/Y/Zaxis - X/Y/Z-axis of the coordinate system
  • XY/XZ/YZ_plane - planes of the coordinate system

Methods

  • Clone - deep copy of object
  • Rotate/RotateDeg - rotate coordinate system around rotation axis
  • Equals - check if two coordinate systems are equals
  • ToString - string representation of coordinate system

Matrix3d

Properties

  • Item(i,j) - element of the matrix
  • Row1/2/3 - rows of the matrix
  • Column1/2/3 - columns of the matrix
  • Det - determinant of the matrix
  • MaxNorm - Max norm of the matrix
  • IsZero - check if matrix is zero matrix
  • IsIdentity - check if matrix is identity matrix
  • IsOrthogonal - check if matrix is orthogonal

Methods

  • Inverse - inverse of the matrix
  • Transpose - transpose of the matrix
  • RotationMatrix - rotation around given axis
  • Equals - check if two matrix are equals
  • ToString - string representation of matrix

GeometRi3D

Properties

  • Tolerance - tolerance used for comparison operations (default 1e-12)

Methods

  • AlmostEqual - tolerance based equality check
  • NotEqual - tolerance based unequality check
  • Greater - tolerance based comparison
  • Smaller - tolerance based comparison

NuGet

GeometRi (fuget.org)
6,457 Total Downloads 10 Downloads Per Day Latest Version: 1.3.5.8 (January 10, 2019) Hide All Versions Show All Versions
Version Downloads Last Updated
51 January 10, 2019
93 December 15, 2018
56 December 12, 2018
462 November 2, 2018
210 October 14, 2018
282 September 15, 2018
324 July 7, 2018
150 June 30, 2018
557 June 20, 2018
224 May 4, 2018
161 April 20, 2018
336 November 27, 2017
304 October 6, 2017
172 September 18, 2017
154 September 11, 2017
172 August 26, 2017
173 August 9, 2017
175 August 4, 2017
193 July 30, 2017
213 July 23, 2017
189 June 21, 2017
186 June 3, 2017
185 May 31, 2017
208 May 21, 2017
194 April 29, 2017
189 April 25, 2017
186 April 23, 2017
10
1
0
Source

{{ 'https://github.com/RiSearcher/GeometRi' | no-protocol }}

NuGet