C# Creating generic Vector4 class? -


Is anyone good the way to create a normal vector 4 square in C #? I have some units (force, distance, moment, rotation, acceleration, velocity etc), which all require 3D representation and they all behave equally and hence supporting basic tasks for adding, multiplying etc. should do.

Each category includes some special cases, for example force_distance = moment so I Vector4 want to be able to create a Force 3D legacy, so I do not have to write all those arrows all the time and these forces should be able to add special tasks to Struct

I am using this legacy-based approach, where every unit was found with vector 4, so far, but it creates some problems because when I add for example (force 1, force) 2), I get a base class, vector 4, instead of a force 3d, so I'm either casting or copying the add-function for each unit.

I have a Vector4 < Double & gt; and vector 4 & lt; Force & gt; Without redefining all basic tasks for adding, multiplying, etc. (primarily with real operators, which seems impossible). It also adds some new problems because the best solution is to get the force double, but all the base types are closed, so I have to make a containerclass and instead I replace the original operators for numbers. I define.

I am trying every possible way, but I always try to redefine too many things.

Overloading operators, a solution that tells how to do this by using a library of net sketts .

To get the right type in the results of the methods, you can use something like this:

  public square vector & lt; T & gt; {Public T X {get; } Receive Public TY {}; }} Public Squared VectorWith Operators & lt; TVCutter, T & gt; : Vector & lt; T & gt; Where TVCctor: Vector & lt; T & gt;, new () Return to Public TV GetSomeResult ()} New TVector (); }} Public Class Force 3D: VectorWith Operators & lt; Force 3D, Double & gt; {}  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -