cleak's picture

VectorN clean up, refactoring, and additions

Project:The Open Toolkit library
Category:feature request

There are some inconsistencies in the different vector structs that I would like to resolve. In particular:

  • The Max and Min methods are component-wise max/min for some vector types and magnitude based for others. It seems logical to make Max() and Min() component-wise so XNA ported code doesn't end up with odd bugs. The magnitude ones could be renamed to MagnitudeMax() and MagnitudeMin().
  • Vector2 defines Transform for quaternions but not matrices.
  • Constructors for promoting to larger vectors aren't always defined (for example Vector3(Vector2, float) doesn't exist).

There are some additional features I would like to see added as well such as CatmullRom interpolation and a compenent-wise vector-vector multiply operator. Some shorthand methods that are replacements for XNA ported code would be nice as well, for example Distance(Vector, Vector). I ran into, and solved, many of these issues when porting Farseer Physics to OpenTK and I'd like to see them rolled into a future version of OpenTK if possible.

It would also be nice to have some way of ensuring consistency between the vector types. With 6 structs all implementing many of the same methods, it seems like there's bound to be discrepancies. Struct inheritance would be ideal for this if it existed. Instead, implementing a generic interface might be the way to go. An interface would also allow for a generic static helper class that could implement things such as CatmullRom, requiring only 1 implementation + 6 wrappers rather than 6 implementations. What thoughts and preferences do people have about this?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture


Status:open» confirmed

These are true issues.

Please create a different bug report (feature request) for CatmullRom, so we can discuss implementation details without littering this bug report.

cleak's picture


Sounds good. I've opened a new issue for the Catmull-Rom interpolation: