/// <summary> /// Snap rotate to some angle. Preserve scale and translation. /// </summary> /// <param name="mat"></param> /// <param name="angle">__ANGLE IS IN DEGREES__</param> /// <returns></returns> public static d2d.Matrix eSnapRotate(this d2d.Matrix mat, double angle) { // Graphics tries to work opposite of OpenGL, in Drawing2D: // PRE - multiply for local // post -multiply for global var curmat = mat.Elements; // get the vector components. var x_axis = new ai.Vector2D(curmat[0], curmat[1]); var y_axis = new ai.Vector2D(curmat[2], curmat[3]); // Get the scale of current matrix double x_len = x_axis.Length(); double y_len = y_axis.Length(); var newmat = new d2d.Matrix(); // Preserve scale and translation // This means: v*M = v*(S * R * T) newmat.Scale((float)x_len, (float)y_len); newmat.Rotate((float)angle); newmat.Translate(curmat[4], curmat[5]); return(newmat.Clone()); }
/// <summary> /// Rescale the matrix. Preserve rotation and translation. /// </summary> /// <param name="mat"></param> /// <returns></returns> public static d2d.Matrix eSnapScale(this d2d.Matrix mat, double scale = 1.0) { var curmat = mat.Elements; // normalise the x and y axis to set scale to 1.0f var x_axis = new ai.Vector2D(curmat[0], curmat[1]); var y_axis = new ai.Vector2D(curmat[2], curmat[3]); x_axis.Normalize(); y_axis.Normalize(); // scale the axis x_axis.X *= (float)scale; x_axis.Y *= (float)scale; y_axis.X *= (float)scale; y_axis.Y *= (float)scale; // make new matrix with scale of 1.0f // Do not change the translation var newmat = new d2d.Matrix(x_axis[0], x_axis[1] , y_axis[0], y_axis[1] , curmat[4], curmat[5] ); return(newmat.Clone()); }
public static OpenTK.Vector2 ToOpenTKVector2(this Assimp.Vector2D vec2) { return(new OpenTK.Vector2(vec2.X, vec2.Y)); }
public static Vector2 ToNumerics(this Ai.Vector2D value) => new Vector2(value.X, value.Y);
public static Vector2 ToNumerics(this Ai.Vector2D value) { return(new Vector2(value.X, value.Y)); }