Skip to content

Aardvark 5.0 changelog

Attila Szabo edited this page Dec 22, 2023 · 1 revision

Aardvark 5 comes with a lot of changes including new features. Some parts of the API were redesigned, requiring developers to manually port their applications from Aardvark 4.x. This document is mainly intended as a reference to make this process easier, but also for interested users to see what's new.

Breaking changes that may not result in build errors

The following changes are especially critical as they only affect the implementation but not the API itself. As such, there will be no compiler errors. It is recommended that developers read this list carefully and search their projects for code that relies on the affected functionality:

  • Changed the parameter order of Vec.reflect, Vec.refract, and clamp to allow for easier piping
  • Adapted Vec.Reflect to be equivalent to GLSL's reflect and F# Vec.reflect
  • Static creators and constructors for rotations in all transformation types and matrix types (e.g. Rot3d(from, into) and Rot3d(axis, angle)) used to work with unnormalized vectors as input. They require normalized vectors now.
  • Indexer of Rot3d uses the quaternion layout (w, (x, y, z)) now instead of (x, y, z, w).
  • GetScale() of M44* uses the 4D basis now. Use GetScale3() for 3D basis.
  • 2D rotations are now counter-clockwise instead of clockwise (e.g. Rot2d(float), M33d.Rotation(float))
  • Multiplication of two Rot2* trafos is a concatenation now (addition of angles). Previously it merely multiplied the contained angles.
  • Equals method and (==) operator of Rot** types use angular distance now. E.g. r and -r for any (r : Rot3d) are equal.
  • Added missing CultureInfo.InvariantCulture to format and parse methods in
    • Plane2d, Plane3d
    • Sphere3d
    • Circle3d
    • ImmutablePolygon
    • Trafo types
  • (>= 5.1) Indexers of the following types no longer throw IndexOutOfRangeException, but will fail silently with horrible consequences:
    • Vector types
    • Matrix types
    • Quaternion types
    • Rot types
    • Scale types
    • Shift types
    • Color types

Redesign of specialized transformation types

The specialized transformation types (Trafo2d, Rot3d, Shift3f, etc.) were reworked to be more consistent with each other. We also added missing variants for 2D and float32 data:

  • All trafo types are available for 2D now
  • Constructors are lightweight and simple
  • Trafos can be "up cast", that is into more general types (e.g. Rot3f into Euclidean3f)
  • For "down casts" there are static creators (e.g. Euclidean3f into Rot3f -> Rot3f.FromEuclidean3f). These creators do sanity checks and throw exceptions.
  • Split functionality of Rot3* into two classes: Added Quaternion* for general quaternions whereas Rot3* represents unit quaternions only.
  • Removed Rot3*.Conjugated -> use Rot3*.Inverse
  • Rot** comparison works based on angular distance now
  • Removed complex Rot** constructors and added static creators instead
  • Removed static aliases for operators like Multiply(). Use the operators directly!
  • Moved static methods of Rot*, Euclidean*, Similarity* to static classes Rot, Euclidean, Similarity respectively.
  • Added Affine** for affine transformations (linear map and translation).
  • Trafo2f and Trafo3f added

Rework of Fun class

The static class Fun, containing essential math and other various methods, was extended to support vector inputs where appropriate. For example, Fun.Sqrt may be used on a V3i vector to compute the square root for each component resulting in a V3d vector. Moreover, functions were renamed, added, and made more efficient:

  • Moved some static methods of Complex* to Fun. Use Fun.Csqrt to compute the complex square roots.
  • Float overloads of certain Fun methods use System.MathF instead of System.Math when available
  • Fun.Smoothstep added
  • Fun.AcosC -> Fun.AcosClamped
  • Fun.AsinC -> Fun.AsinClamped
  • Fun.FloatToBits and Fun.FloatFromBits added
  • Fun.IsFinite added
  • Fun.MultiplyAdd added
  • Fun.Pown added
  • Fun.Truncate added
  • Fun.Saturate added
  • Fun.Signum and Fun.Signumi added
  • Fun.CopySign added
  • ApproxEqual -> ApproximateEquals in Fun class as extensions
  • Most methods in Fun work elementwise for vectors now

Better F# interoperability for custom types

Some of our custom types now have properties that make it possible to use them in various generic F# functions. For example, it is now possible to compute the sum of a list of vectors:

let data = [V3i(1, 2, 3); V3i(3, 4, 5)]
let sum = data |> List.sum

Generic math for F#

We've added a generic math library for F#. Like many methods in Fun, these functions work for scalars as well as vectors. They are truly generic, making it possible to use custom-defined types (if the type satisfies the respective constraints):

  • zero
  • one
  • acos
  • acosh
  • asin
  • asinh
  • atan
  • atanh
  • atan2
  • cos
  • cosh
  • sin
  • sinh
  • tan
  • tanh
  • ceiling
  • floor
  • truncate
  • round
  • exp
  • log
  • log2
  • log10
  • sqrt
  • pow
  • pown
  • sqr
  • cbrt
  • abs
  • signum
  • signumi
  • min
  • max
  • clamp
  • saturate
  • lerp
  • smoothstep
  • copysign
  • degrees
  • radians
  • madd
  • isNaN
  • isInfinity
  • isPositiveInfinity
  • isNegativeInfinity
  • isFinite

Changes to matrix (and trafo) types

  • Renamed matrix and trafo static creators Rotation(V3*) -> RotationEuler(V3*)
  • Renamed matrix and trafo static creators Rotation(real, real, real) -> RotationEuler(real, real, real)
  • Renamed trafo static creators RotationInDegrees(V3*) -> RotationEulerInDegrees(V3*)
  • Renamed trafo static creators RotationInDegrees(real, real, real) -> RotationEulerInDegrees(real, real, real)
  • Renamed Rot**.FromEulerAngles -> Rot**.RotationEuler
  • Renamed matrix static creator M***.Rotation(V3*, V3*) -> M***.RotateInto(V3*, V3*)
  • Renamed matrix property Det -> Determinant
  • Added matrix constructor with single value
  • Added M34* constructor from M33* and V3*
  • Added Diagonal property for matrices and AntiDiagonal for square matrices
  • Added FromDiagonal and FromAntiDiagonal static creators for matrices and square matrices respectively
  • Added vector-matrix multiplication, where the vector is treated as row vector. E.g
    let mul (m : M33f) (v : V3f) = m * v
    let mul' (m : M33f) (v : V3f) = v * m.Transposed
    
    are equivalent.
  • Removed InvTransform* from general matrix types

Changes to vector types

  • Moved static methods of vector types to static class Vec. E.g., V3d.Dot -> Vec.Dot
  • Merged VecFun with new Vec static class
  • Added AngleBetween methods to compute the angle between two vectors (includes a fast naive and a slower more accurate variant)
  • Renamed V**.OuterProduct -> Vec.Outer or v.Outer
  • Vec.DistanceSquared returns the field type of the vector. E.g V2i * V2i -> int
  • Added missing Normalized, Rot* properties for integer vectors
  • Added conversion function overloads for vector types in Conversion class
  • Removed Average over array of vectors -> use ComputeCentroid
  • Deleted obsolete Vec class, use Vector for n-dimensional vectors instead
  • Abs -> Abs()
  • Floor -> Floor()
  • Ceiling -> Ceiling()
  • Round -> Round()
  • Negated -> operator (-)

Other changes

  • Renamed BoxFun -> Box / Range
  • Box**.Intersection -> Box.Intersection
  • Box**.Union -> Box.Union
  • Moved static methods of color types to static class Col.
  • Col.LinComRawC*f -> Col.LinComRawF, Col.LinComRawC*d -> Col.LinComRawD
  • ImageTrafo.Rot0 renamed to ImageTrafo.Identity
  • Removed ColFun
  • Added various missing IRandomSystem methods for vectors and colors
  • Fixed and added various functions for Complex*
  • Changed Equals method of various types to use Equals on their fields to be consistent with float.Equals and double.Equals (NaN.Equals(NaN) == true whereas NaN != NaN).