sourceforge project page - rule-based mesh growing
Vecmath is a comprehensive library for vector arithmetics. Its written in C# and its main focus is on computer graphics applications.
All types are named using the following scheme: Name<dim><type>
2-dimensional | 3-dimensional | |||||||
---|---|---|---|---|---|---|---|---|
double | float | long | int | double | float | long | int | |
point | Pnt2D | Pnt2F | Pnt3D | Pnt3F | ||||
vector | Vec2D | Vec2F | Vec2L | Vec2I | Vec3D | Vec3F | ||
ray | Ray2D | Ray2F | Ray3D | Ray3F | ||||
box | Box2D | Box2F | Box3D | Box3F | ||||
translation | Shift2D | Shift2F | Shift3D | Shift3F | ||||
scale | Scale2D | Scale2F | Scale3D | Scale3F | ||||
rotation | Rot2D | Rot2F | Rot3D | Rot3F | ||||
general transformation | Trafo2D | Trafo2F | Trafo3D | Trafo3F |
Example: A 2-dim point at coordinates p(10,17) should be rotated 90 degrees ccw, with the center of rotation at coordinates c(7,3).
Pnt2D p = new Pnt2D(10, 17); Pnt2D c = new Pnt2D(7,3); Trafo2D transform = new Shift2D(-c) // shift center of rotation to origin * new Rot2D(Math.PI / 2.0) // rotate * new Shift2D(c) // shift back ; Pnt2D p_transformed = p * transform; System.Console.WriteLine("p: " + p); System.Console.WriteLine("c: " + c); System.Console.WriteLine("result: " + p_transformed);
Output: p: Pnt2D(10, 17) c: Pnt2D(7, 3) result: Pnt2D(-7, 6)