internal static DSCoordinateSystem ByOriginVectors(DSPoint origin, DSVector xAxis, DSVector yAxis, DSVector zAxis, bool isSheared, bool isNormalized, bool visible) { if (origin == null) throw new System.ArgumentNullException("origin"); else if (xAxis == null) throw new System.ArgumentNullException("xAxis"); else if (yAxis == null) throw new System.ArgumentNullException("yAxis"); else if (zAxis == null) throw new System.ArgumentNullException("zAxis"); else if (xAxis.IsZeroVector()) throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "x axis"), "xAxis"); else if (yAxis.IsZeroVector()) throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "y axis"), "yAxis"); else if (zAxis.IsZeroVector()) throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "z axis"), "zAxis"); else if (xAxis.IsParallel(yAxis)) throw new System.ArgumentException(string.Format(Properties.Resources.IsParallel, "x axis", "y axis", "DSCoordinateSystem.ByOriginVectors"), "xAxis, yAxis"); else if (!isSheared && (!xAxis.IsPerpendicular(yAxis) || !yAxis.IsPerpendicular(zAxis) || !zAxis.IsPerpendicular(xAxis))) { // this is not the case for sheared but axes are not orthogonal // zAxis = xAxis.Cross(yAxis); yAxis = zAxis.Cross(xAxis); } if (isNormalized) { xAxis = xAxis.Normalize(); yAxis = yAxis.Normalize(); zAxis = zAxis.Normalize(); } var cs = HostFactory.Factory.CoordinateSystemByData(null); //create identity matrix if (null == cs) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSCoordinateSystem.ByOriginVectors")); cs.Set(origin.PointEntity, xAxis.IVector, yAxis.IVector, zAxis.IVector); var coordSys = new DSCoordinateSystem(cs, visible); return coordSys; }