This is the sort of thing you either do or don't recognize its usefulness so I'll leave it at that.
The source is available on github here: DinkVector
I am providing source for my common languages: C#, javascript, lua, and a generated VB version for you VBers out there. (These will show up on github as I finish porting to them)
The basic interface is as follows:
- public class DinkVector
- {
- double X { get; set; }
- double Y { get; set; }
- double Z { get; set; }
- DinkVector() { }
- DinkVector(double x, double y, double z);
- DinkVector(DinkVector dinkVector);
- static DinkVector FromX(double xAngle, double length);
- static DinkVector FromY(double yAngle, double length);
- static DinkVector FromZ(double zAngle, double length);
- static DinkVector FromZX(double zAngle, double xAngle, double length);
- static DinkVector FromZY(double zAngle, double yAngle, double length);
- static DinkVector FromXY(double xAngle, double yAngle, double length);
- DinkVector Add(DinkVector dinkVector);
- DinkVector Add(double x, double y, double z);
- static DinkVector operator +(DinkVector left, DinkVector right);
- DinkVector Subtract(DinkVector dinkVector);
- DinkVector Subtract(double x, double y, double z);
- static DinkVector operator -(DinkVector left, DinkVector right);
- DinkVector Multiply(DinkVector dinkVector);
- DinkVector Multiply(double x, double y, double z);
- static DinkVector operator *(DinkVector left, DinkVector right);
- DinkVector Divide(DinkVector dinkVector);
- DinkVector Divide(double x, double y, double z);
- static DinkVector operator /(DinkVector left, DinkVector right);
- DinkVector Modulo(DinkVector dinkVector);
- DinkVector Modulo(double x, double y, double z);
- static DinkVector operator %(DinkVector left, DinkVector right);
- void Negate();
- void Normalize();
- double Length { get; set; }
- double GetLengthFrom(DinkVector dinkVector);
- double GetLengthFrom(double x, double y, double z);
- void SetLengthFrom(DinkVector dinkVector, double length);
- void SetLengthFrom(double x, double y, double z, double length);
- double ZAngle { get; set; }
- double GetZAngleFrom(DinkVector dinkVector);
- double GetZAngleFrom(double x, double y);
- void SetZAngleFrom(DinkVector dinkVector, double angle);
- void SetZAngleFrom(double x, double y, double angle);
- double XAngle { get; set; }
- double GetXAngleFrom(DinkVector dinkVector);
- double GetXAngleFrom(double z, double y);
- void SetXAngleFrom(DinkVector dinkVector, double angle);
- void SetXAngleFrom(double z, double y, double angle);
- double YAngle { get; set; }
- double GetYAngleFrom(DinkVector dinkVector);
- double GetYAngleFrom(double x, double z);
- void SetYAngleFrom(DinkVector dinkVector, double angle);
- void SetYAngleFrom(double x, double z, double angle);
- double ZAngleStep { get; }
- double XAngleStep { get; }
- double YAngleStep { get; }
- }