Skip to content

Vector, Vector3D, Point and Point3D for netstandard1.3

License

A1essandro/VectorAndPoint.NetStandard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VectorAndPoint.NetStandard

Vector, Vector3D, Point and Point3D for netstandard1.3

Points

There are several types (structs) of points available:

Point - point with coordinates of type double

using VectorAndPoint.ValTypes;
//...........................
var point = new Point(0.5, 10.3);

PointInt - point with coordinates of type int

using VectorAndPoint.ValTypes;
//...........................
var point = new PointInt(1, 2);

Point3D - point with coordinates of type double in three-dimensional space

using VectorAndPoint.ValTypes;
//...........................
var point = new Point3D(1, 2, 3);

Vectors

There are two types (structs) of vectors available:

Vector - vector with coordinates of type double

using VectorAndPoint.ValTypes;
//...........................
var vector = new Vector(0.5, 10.3);

Vector3D - vector with coordinates of type double in three-dimensional space

using VectorAndPoint.ValTypes;
//...........................
var vector = new Vector3D(1, 2, 3);

Usage

Common

All types overrides method ToString() for representating value as (X, Y) for two-dimensional and (X, Y, Z) for three-dimensional structure.

Comparison via Equals() or operators == and != has compare each coordinate or component of both structure.

Addition of a point and a vector

var point = new Point(0.5, 3.14);
var vector = new Vector(1, 2);
var resultVector1 = point + vector; //result is point with coordinates (1.5, 5.14)
var resultVector2 = vector + point; //result is point with coordinates (1.5, 5.14)

Points behaviors

Point has static method GetRangeBetween() for calculation of range between two points.

Vectors behaviors

Operators

You can multiply a vector by a number to change the length of a vector. You can also add two vectors together.

var vector1 = new Vector(1, 2);
var factor = 3; //int, double or float
var vector2 = vector1 * factor; //(3, 6)
var vector1PlusVector2 = vector1 + vector2 //(4, 8)

Scalar product of two vectors:

var vector1 = new Vector(1, 0);
var vector2 = new Vector(2, 2);
double result = vector1.GetScalarProductWith(vector2); // 2
//or static
double result = Vector.GetScalarProduct(vector1, vector2); // 2

Checking vectors collinearity:

var vector1 = new Vector(1, 0);
var vector2 = new Vector(2, 2);
bool result = vector1.IsCollinearWith(vector2); // false
//or static
bool result = Vector.IsCollinear(vector1, vector2); // false

About

Vector, Vector3D, Point and Point3D for netstandard1.3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages