Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Just 3 comments:</p> <p>1)In C#, we usually expose properties instead of fields. That is, </p> <pre><code> public float X {get; private set;} public float Y {get; private set;} </code></pre> <p>2) The type double gives a higher precision than float, so i would advise you to use double instead of float.</p> <p>3) You overloaded one of your operators as :</p> <pre><code> public static float operator *(Vector2 v1, Vector2 v2) { return v1.X * v2.X + v1.Y * v2.Y; } </code></pre> <p>Which I take to be the dot (inner product) of two 2d real vectors. In programming, when we overload an operator, the overload should do what the operator does. That is, if we were to overload the operator *(Vector2 v1, Vector2 v2), the overload should multiply these two vectors together. However, there is no definite definition of "multiplication" for two vectors. Using the term "multiplication" in linear algebra is extremely vague. You could be referring to tensor products, outer products, inner products, cross products, scalar product, etc. So to make your code less confusing, I would recommend you implement the inner product operator as</p> <pre><code>public static float InnerProduct(Vector2 v1, Vector v2) </code></pre> <p>instead.</p> <p>As for a better implementation of the square root function, Math.Sqrt is probably one of the fastest one (in the .NET framework). If you were thinking of improving the speed of your class, then writing it in native C/C++ and then writting a managed wrapper for it will probably give you the most improvements.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload