Closed wiwalsh closed 2 years ago
OK. Let me ask a more concise question. If I wanted to use a generic class to instantiate a unit to a value, how would I do that (for some silly reason)? Once I get the above classes working, I don't mind sharing, but I'm not sure if it is of interest to anyone.
Function Call
var instance = new TestClass<Length>(4.5)
Somehow in the below class I need to assign the value to whatever the default unit is for that unit type. I'm semi lost between generics and how this library works.
Class
public class TestClass<T> where T : BaseUnit
{
private T singleValue;
public TestClass(double input)
{
singleValue = new T(input);
}
}
That will be great with a vector and matrix class! You dont really need a generic class for this, we do it a bit differently here.
I have started on a vector class for you in Math ->Vector.cs
Just a quick go I have added this:
Power p1 = new Power(5,PowerUnit.SI);
Power p2 = new Power(10, PowerUnit.SI);
Power p3 = new Power(15, PowerUnit.SI);
UVector v1 = new UVector(p1, p2);
UVector v2 = v1 + v1;
Power PDot = UVector.DotProduct(v1, v1);
UVector v3 = new UVector(p1, p2, p3);
UVector v4 = new UVector(p2, p2, p2);
UVector PCross = UVector.CrossProduct(v3, v4);
Feel free to change it or add to it all you want and also check if what I have done is even correct.
Awesome! I'll start adding things and my tests for those functions.
Let me know if you need help with anything!
I have a vector and matrix class that I had written for UnitsNet that I am trying to convert over to EngineeringUnits and having some trouble.
I have included the whole class, but there are two basic areas I am having trouble understanding how to implement. Since this is a generic class, I am having trouble initializing the values of the array to a value. I am also having trouble assigning the values of the EngineeringUnits overloaded operators back to. I get