All Projects → LinusVanElswijk → Unity-Int-Vectors

LinusVanElswijk / Unity-Int-Vectors

Licence: MIT License
Library that adds Vector2i and Vector3i classes, which are integer counterparts to Vector2 and Vector3.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to Unity-Int-Vectors

Graphical Debugging
GraphicalDebugging extension for Visual Studio
Stars: ✭ 88 (+282.61%)
Mutual labels:  geometry, vector
Sharpmath
A small .NET math library.
Stars: ✭ 36 (+56.52%)
Mutual labels:  geometry, vector
Maker.js
📐⚙ 2D vector line drawing and shape modeling for CNC and laser cutters.
Stars: ✭ 1,185 (+5052.17%)
Mutual labels:  geometry, vector
Svg.skia
An SVG rendering library.
Stars: ✭ 122 (+430.43%)
Mutual labels:  geometry, vector
Elm Geometry
2D/3D geometry package for Elm
Stars: ✭ 162 (+604.35%)
Mutual labels:  geometry, vector
vg
Vector-geometry toolbelt for 3D points and vectors
Stars: ✭ 106 (+360.87%)
Mutual labels:  geometry, vector
Mathematics for Machine Learning
Learn mathematics behind machine learning and explore different mathematics in machine learning.
Stars: ✭ 28 (+21.74%)
Mutual labels:  geometry, vector
ludigraphix.github.io
Documentation for Ludigraphix
Stars: ✭ 21 (-8.7%)
Mutual labels:  geometry, vector
Clarity
Customizable Monoshape Vector Icon Theme for GTK+
Stars: ✭ 37 (+60.87%)
Mutual labels:  vector
PGS
Processing Geometry Suite
Stars: ✭ 39 (+69.57%)
Mutual labels:  geometry
geoh
Transform a geoJSON into a list of geohashes that intersect with it
Stars: ✭ 26 (+13.04%)
Mutual labels:  geometry
ara
The PULP Ara is a 64-bit Vector Unit, compatible with the RISC-V Vector Extension Version 0.10, working as a coprocessor to CORE-V's CVA6 core
Stars: ✭ 116 (+404.35%)
Mutual labels:  vector
rrbit-js
No description or website provided.
Stars: ✭ 11 (-52.17%)
Mutual labels:  vector
geometrycommands
Commandline application for manipulating geometry.
Stars: ✭ 24 (+4.35%)
Mutual labels:  geometry
birkhoff
Euclidean plane and its relatives; a minimalist introduction.
Stars: ✭ 15 (-34.78%)
Mutual labels:  geometry
milvus.io
Milvus official website.
Stars: ✭ 26 (+13.04%)
Mutual labels:  vector
pypoman
Python module for polyhedral geometry
Stars: ✭ 26 (+13.04%)
Mutual labels:  geometry
TriangleMeshDistance
Header only, single file, simple and efficient C++11 library to compute the signed distance function (SDF) to a triangle mesh
Stars: ✭ 55 (+139.13%)
Mutual labels:  geometry
vecti
A tiny TypeScript library for 2D vector math.
Stars: ✭ 14 (-39.13%)
Mutual labels:  vector
d3.geometer
[NOT MAINTAINED] A D3js library for drawing polytopes, angles, coordinates, geometries and more.
Stars: ✭ 18 (-21.74%)
Mutual labels:  geometry

Unity Int Vectors

This library provides integer vectors, Vector2i and Vector3i. These are integer variants of Unity's Vector2 and Vector3 classes and implement all functionality that you would expect.

A familiar interface

Vector2i and Vector3i use the same interface as Vector2 and Vector3. Practically every function that is defined for Vector2/Vector3 is also defined for Vector2i/Vector3i.

Usefull predifined values

All the predifined values from Vector2/Vector3 are also defined for Vector2i/Vector3i:

  • zero (Vector2i and Vector3i)
  • one (Vector2i and Vector3i)
  • up (Vector2i and Vector3i)
  • down (Vector2i and Vector3i)
  • left (Vector2i and Vector3i)
  • right (Vector2i and Vector3i)
  • forward (only Vector3i)
  • back (only Vector3i)

All operators are implemented

All mathematical and equality operations are supported:

  var minus_two = -2 * vector3i.one;
  var treasure_location = 5 * vector2i.right + 3 * vector2i.up;
  var b = -vector2i.one == vector2i.one + minus_two;

Effortless integration

No need to rewrite all your exisiting code. Just call any function accepting Vector2/Vector3 and pass it a Vector2i/Vector3i! Of course this also works with any third party library you are using or are planning to use. Implicit conversion from int to float types does all the work for you.

Implicit conversion only happens from int to float and not the other way around, so this won't accidentally cause rounding errors:

   public static Vector3 f(Vector3 x) { ... }
   public static Vector3i g(Vector3i x) { ... }
   
   ...
   
   Vector3 a;
   Vector3i b;
   
   ...
   
   Vector3  r0 = f(b);            // OK
   Vector3i r1 = f(b);            // Compile Error - potential bug by accidentally casting float to int
   Vector3i r2 = (Vector3i)f(r2); // OK - make it explicit if it really is what you want to do
   Vector3  r3 = g(a);            // OK
   Vector3i r4 = g(b);            // Compile Error - potential bug by accidentally casting float to int
   vector3i r5 = g((Vector3i)b);  // OK -  make it explicit if it really is what you want to do

RectLoops and CubeLoops

The library also adds new control structures, that make it easier to loop over values of vectors.

// Where you would normally write
for(int x = 0; x < 10; ++x) {
  for(int y = 2; y < 12; ++y) {
    MyFunction(new Vector(x, y));
  }
}

// you can write
RectLoop(
  new Vector2i(0, 2),
  new Vector2i(10, 12),
  MyFunction
);


// Where you would normally write
for(int x = 0; x < 10; ++x) {
  for(int y = 2; y < 12; ++y) {
    for(int z = -4; z < 8; ++z) {
      MyFunction(new Vector(x, y, z));
    }
  }
}

// you can write
CubeLoop(
  new Vector3i(0, 2, -4), 
  new Vector3i(10, 12, 8), 
  MyFunction
);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].