public static GsVector ComputeProjectileDirection(float angle) { GsVector v = new GsVector(1, 0); GsMatrix rotMatrix = GsMatrix.CreateRotationZ(angle); return(GsVector.Transform(v, rotMatrix)); }
/// <summary></summary> public GsPolygon GetHull(GsVector offset) { GsVector[] polygon = GetImageHull(); if (hullCache == null || Bounds != previousBounds) { GsMatrix transform = CreateTransform(GetTextureDrawData(offset)); hullCache = new GsPolygon(polygon, transform); previousBounds = Bounds; } return(hullCache); }
/// <summary></summary> protected virtual GsMatrix CreateTransform(ImageParams data) { // create the matrix for transforming the center GsMatrix transform = GsMatrix.CreateTranslation(-data.Origin.X, -data.Origin.Y, 0) * GsMatrix.CreateRotationZ(Orientation) * GsMatrix.CreateScale(data.Scale.X, data.Scale.Y, 1f) * GsMatrix.CreateTranslation(data.Position.X, data.Position.Y, 0); // return the transform return(transform); }
/// <summary></summary> protected virtual GsVector GetCenter(GsVector offset) { // get the drawing data ImageParams data = GetTextureDrawData(offset); // get the center of the image GsVector center = data.ImageSize.ToVector() / 2f; // compute the transform GsMatrix transform = CreateTransform(data); // return the center transformated return(GsVector.Transform(center, transform)); }