Adding new methods to the default Vector class

We are thinking of adding a bit of customization to the default Vector class to add some extra functionality. We have two changes in mind and wanted to get some feedback before proceeding:

  1. Overload -,+,* operators to help with vector operations. This would need to be within the vector class itself.
  2. Create methods like DotProduct, UnitVector, Norm, etc to perform other standard linear algebra operations. This could be defined in the vector class or an extension class
2 Likes

Hi @GerardTaig - welcome! (if you want to, do Introduce yourself 🙆!)

Sounds like a reasonable thing to do. I’m mostly curious what you’re planning to do with this algebra down the line! We’ll keep an eye out for the PR and we can discuss implementation details there. Regarding 2), I wouldn’t mind having the Dot, Unit, Norm functions in the original class as well to start with.

I’ll leave the implementation pattern up to you and the rest of the people reading this for now - I don’t have much experience in how this kind of functionality should be structured beyond how threejs does it.

1 Like

Hi @GerardTaig,

How are these Vector operations coming along?
I would indeed also be very interested in not having to write these basic operations myself for each Speckle implementation.

Cheers,
Kelvin

Hey @kelvin - @GerardTaig implemented some vector operations here. These changes haven’t been pushed upstream to the speckle-systems repo yet, but we are happy to make a PR! Take a look at let us know if this covers what you’ve been thinking about.

Cheers,
Jenessa

1 Like

Hi @jenessa.man,

That surely is a good start, thanks for sharing!
I’d like to refer to the comment of @dimitrie in this post that it might be best to provide these operators as a separate project, outside of the Object model. Any thoughts about this?

Cheers,
Kelvin

1 Like

Just to quickly clarify on this: when i said separate project, i just mean a separate .csproj file :slight_smile: So nothing dramatic like a new repo, etc. - we’re happy to have in them in sharp.

1 Like