/// <summary> /// verify is this cs is equals to otherByLayer ( same origin, x, y, z base vectors ) /// </summary> /// <param name="tol">calc tolerance ( for origin check )</param> /// <param name="other">cs to check equality against</param> /// <returns>true if this cs equals the given on, false otherwise</returns> /// <remarks> /// [unit test](/test/Vector3D/Vector3DTest_0001.cs) /// </remarks> public bool Equals(double tol, CoordinateSystem3D other) { return(Origin.EqualsTol(tol, other.Origin) && BaseX.EqualsTol(tol, other.BaseX) && BaseY.EqualsTol(tol, other.BaseY) && BaseZ.EqualsTol(tol, other.BaseZ)); }
/// <summary> /// Overrides GetHashCode. /// </summary> /// <returns></returns> public override int GetHashCode() { return(BaseO.GetHashCode() + BaseX.GetHashCode() + BaseY.GetHashCode() + BaseZ.GetHashCode()); }
/// <summary> /// return another cs with same origin and base vector rotated about given vector /// </summary> public CoordinateSystem3D Rotate(Vector3D vectorAxis, double angleRad) { return(new CoordinateSystem3D( Origin, BaseX.RotateAboutAxis(vectorAxis, angleRad), BaseY.RotateAboutAxis(vectorAxis, angleRad), BaseZ.RotateAboutAxis(vectorAxis, angleRad))); }
public CoordinateSystem3D(Vector3D o, Vector3D normal, CoordinateSystem3DAutoEnum csAutoType = CoordinateSystem3DAutoEnum.AAA) { Origin = o; switch (csAutoType) { case CoordinateSystem3DAutoEnum.AAA: { Vector3D Ax = null; if (Abs(normal.X) < aaaSmall && Abs(normal.Y) < aaaSmall) { Ax = Vector3D.YAxis.CrossProduct(normal).Normalized(); } else { Ax = Vector3D.ZAxis.CrossProduct(normal).Normalized(); } var Ay = normal.CrossProduct(Ax).Normalized(); BaseX = Ax; BaseY = Ay; BaseZ = Ax.CrossProduct(Ay).Normalized(); } break; case CoordinateSystem3DAutoEnum.St7: { BaseZ = normal.Normalized(); // axis 2 if (BaseZ.IsParallelTo(Constants.NormalizedLengthTolerance, Vector3D.ZAxis)) { BaseY = Vector3D.YAxis; } else { BaseY = Vector3D.ZAxis.CrossProduct(BaseZ).Normalized(); } // axis 1 BaseX = BaseY.CrossProduct(BaseZ).Normalized(); } break; } m = Matrix3D.FromVectorsAsColumns(BaseX, BaseY, BaseZ); mInv = m.Inverse(); }
/// <summary> /// Overrides the Equals-method. Two bases are equal, if the parameter BaseO, BaseX,BaseY and BaseZ are equals /// in the sense of <see cref="xyz.Equals"/>. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (obj is Base) { Base Other = (Base)obj; return(BaseO.Equals(Other.BaseO) && BaseX.Equals(Other.BaseX) && BaseY.Equals(Other.BaseY) && BaseZ.Equals(Other.BaseZ)); } else if (obj is String) { return(true); } return(base.Equals(obj)); }
{ /// <summary> /// Calculates a string belonging to the Base.e.g. to the unit base you get 0/0/0; 1/0/0; 0/1/0/;0/0/1 /// </summary> /// <returns>string belonging to the Base</returns> public override string ToString() { return("[" + BaseO.ToString() + ";" + BaseX.ToString() + ";" + BaseY.ToString() + ";" + BaseZ.ToString() + "]"); }