0

I'm putting together a Nim wrapper for Box2D using c2nim.

Box2D has its own mathematical vector class, b2Vec2. If I were using Box2D in raw C++, I'd just use that class. Simple.

But Nim already has such functionality in the basic2d module's Vector2d type.

I want my wrapper's interface to use the built-in Vector2d type so that users of this wrapper don't have to mentally juggle two different vector types. This entails somehow using Vector2d as a Nim interface to b2Vec2. How can I do this?

Things of note:

  • Both b2Vec2 and Vector2d are made of just two 32-bit floats. I'm wrong. Nim floats are 64-bit.
  • Vector2d is part of the Nim standard library, so I can't modify its definition.
  • I'll create a wrapper for b2Vec2 if I have to, but I'd like to avoid doing so, and I definitely don't want users to see it.
Grzegorz Adam Hankiewicz
  • 7,349
  • 1
  • 36
  • 78
JesseTG
  • 2,025
  • 1
  • 24
  • 48

1 Answers1

0

Actually, it doesn't look like I can do this, at least not between basic2d.Vector2d and b2Vec2. The former is made of two 64-bit floats, and the latter is made of two 32-bit floats.

JesseTG
  • 2,025
  • 1
  • 24
  • 48