/// <summary> /// When changing the properties of the coordinate systen (e.g. reversing x-axis), the axis including ticks and labels will move from one end of the graph to the other. /// In order to keep the axes at their location, new <see cref="CSLineID"/>s have to be found for the new coordinate system, that correspond to the same axis location /// in the old coordinate system. This function returns a new <see cref="CSLineID"/>, or null if no corresponding <see cref="CSLineID"/> could be found. /// </summary> /// <param name="oldCoordinateSystem">The old coordinate system.</param> /// <param name="oldLineID">The old line identifier of the axis.</param> /// <param name="newCoordinateSystem">The new coordinate system.</param> /// <returns>The new line identifier, that refers to the same location in the new coordinate systems as the old line identifer referes in the old coordinate system. If no such /// identifer could be found, null is returned.</returns> public static CSLineID FindCorrespondingCSLineIDWhenChangingCoordinateSystem(G3DCartesicCoordinateSystem oldCoordinateSystem, CSLineID oldLineID, G3DCartesicCoordinateSystem newCoordinateSystem) { var oldAxisLineVector = oldCoordinateSystem.GetTransformedAxisLineVector(oldLineID); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 2; ++j) { for (int k = 0; k < 2; ++k) { var newLineID = new CSLineID(i, j, k); var newAxisLineVector = newCoordinateSystem.GetTransformedAxisLineVector(newLineID); if (oldAxisLineVector == newAxisLineVector) { return(newLineID); } } } } return(null); }
/// <summary> /// Finds the corresponding new axis side when changing the coordinate system. /// </summary> /// <param name="oldCoordinateSystem">The old coordinate system system.</param> /// <param name="oldLineID">The old line identifier of the axis.</param> /// <param name="oldAxisSide">The old axis side.</param> /// <param name="newCoordinateSystem">The new coordinate system.</param> /// <param name="newLineID">The new line identifier of the axis (in the new coordinate system).</param> /// <returns>The new axis side. The new axis side as vector in the new coordinate system has the same direction as the old axis side vector in the old coordinate system. /// The return value is null if no axis side with the same direction could be found (this is the case for instance when exchanging x and y axis).</returns> public static CSAxisSide?FindCorrespondingAxisSideWhenChangingCoordinateSystem(G3DCartesicCoordinateSystem oldCoordinateSystem, CSLineID oldLineID, CSAxisSide oldAxisSide, G3DCartesicCoordinateSystem newCoordinateSystem, CSLineID newLineID) { var t_oldAxisSide = oldCoordinateSystem.GetTransformedAxisSideVector(oldLineID, oldAxisSide); var u_newAxisSide = newCoordinateSystem.VectorTransformation.InverseTransform(t_oldAxisSide); try { return(GetAxisSide(newLineID, u_newAxisSide)); } catch (Exception) { return(null); } }