public Line(float[] start_0, float[] end_1):base() { this.loc = new Vector2f(0, 0); this.closest = new Vector2f(0, 0); this.type = ShapeType.LINE_SHAPE; Set(start_0, end_1); }
public static Vector2f ElasticForce(Vector2f displacement, float forceConstant) { float forceX = -forceConstant * displacement.GetX(); float forceY = -forceConstant * displacement.GetY(); Vector2f theForce = new Vector2f(forceX, forceY); return theForce; }
public PConcavePolygonShape(float[] xvers, float[] yvers, float density) { fig = new PFigure(); tri = new PTriangulator(); poly = new PPolygonizer(); numVertices = xvers.Length; localVers = new Vector2f[numVertices]; vers = new Vector2f[numVertices]; _dens = density; for (int i = 0; i < numVertices; i++) { localVers[i] = new Vector2f(xvers[i], yvers[i]); vers[i] = new Vector2f(xvers[i], yvers[i]); } fig.Figure(localVers, numVertices); numVertices = fig.numVertices; localVers = new Vector2f[numVertices]; vers = new Vector2f[numVertices]; for (int i_0 = 0; i_0 < numVertices; i_0++) { localVers[i_0] = new Vector2f(fig.done[i_0].x, fig.done[i_0].y); vers[i_0] = new Vector2f(fig.done[i_0].x, fig.done[i_0].y); } tri.Triangulate(fig.done, fig.numVertices); poly.Polygonize(tri.triangles, tri.numTriangles); convexes = new PConvexPolygonShape[1024]; for (int i_1 = 0; i_1 < poly.numPolygons; i_1++) { convexes[i_1] = new PConvexPolygonShape(poly.polygons[i_1].xs, poly.polygons[i_1].ys, _dens); } numConvexes = poly.numPolygons; CalcMassData(); _type = PShapeType.CONCAVE_SHAPE; }
public Line(Vector2f start_0, Vector2f end_1) : base() { this.loc = new Vector2f(0, 0); this.closest = new Vector2f(0, 0); Set(start_0, end_1); }
public static LNScaleTo Action(float duration, Vector2f s) { LNScaleTo to = new LNScaleTo(); to._duration = duration; to._endX = s.x; to._endY = s.y; return to; }
public PPhysManager(float s, float gx, float gy) { this.world = new PPhysWorld(); this.gravity = new Vector2f(gx, gy); this.start = false; this.enableGravity = true; this.scale = s; }
private PPolygonPolygonCollider.PWContactedVertex [] ClipEdge(PPolygonPolygonCollider.PWContactedVertex [] clips, Vector2f normal, float dist) { PPolygonPolygonCollider.PWContactedVertex [] line = new PPolygonPolygonCollider.PWContactedVertex [2]; int numClips = 0; float dist0 = normal.Dot(clips[0].v) - dist; float dist1 = normal.Dot(clips[1].v) - dist; if (dist0 < 0.0F) { line[numClips] = clips[0]; numClips++; } if (dist1 < 0.0F) { line[numClips] = clips[1]; numClips++; } if (numClips == 0) return null; if (numClips == 2) return line; int c = 0; if (dist0 < 0.0F && dist1 > 0.0F) c = 1; float d = dist0 / (dist0 - dist1); line[1] = new PPolygonPolygonCollider.PWContactedVertex (); line[1].v = clips[1].v.Sub(clips[0].v).Clone(); line[1].v.MulLocal(d); line[1].v.AddLocal(clips[0].v); line[1].data = clips[c].data; return line; }
public LObjectCamera(RectBox r, object f, int width, int height, int horBorderPixel_0, int vertBorderPixel_1, Vector2f maxSpeed_2) { this.cameraX = 0; this.cameraY = 0; this.renderWidth = width; this.renderHeight = height; this.follow = new Bind(f); this.horBorderPixel = horBorderPixel_0; this.vertBorderPixel = vertBorderPixel_1; this.maxSpeed = maxSpeed_2; if (follow != null) { this.cameraX = follow.GetX() - (this.renderWidth / 2); this.cameraY = follow.GetY() - (this.renderHeight / 2); } this.cameraRect = r; this.visibleRect = new RectBox(cameraX - horBorderPixel_0, cameraY - vertBorderPixel_1, renderWidth + horBorderPixel_0, renderHeight + vertBorderPixel_1); this.moveRect = new RectBox(cameraX - horBorderPixel_0, cameraY - vertBorderPixel_1, renderWidth + horBorderPixel_0, renderHeight + vertBorderPixel_1); this.UpdateCamera(); }
internal override void Update() { relAnchor = b.mAng.Mul(localAnchor); anchor.Set(relAnchor.x + b.pos.x, relAnchor.y + b.pos.y); if (b.rem || b.fix) { rem = true; } }
public override void SetTarget(LNNode node) { base._firstTick = true; base._isEnd = false; base._target = node; this._orgPos = node.GetPosition(); this._diff = this._pos.Sub(this._orgPos); }
public static Vector2f GetVelocity(Vector2f velocity, Vector2f force, float mass) { Vector2f acceleration = new Vector2f(force.GetX() / mass, force.GetY() / mass); velocity.Add(acceleration); return velocity; }
private static Vector2f CreateOrigin(LObject o, Origin origin) { Vector2f v = new Vector2f(o.X(), o.Y()); switch (origin) { case Origin.CENTER: v.Set(o.GetWidth() / 2f, o.GetHeight() / 2f); return v; case Origin.TOP_LEFT: v.Set(0.0f, o.GetHeight()); return v; case Origin.TOP_RIGHT: v.Set(o.GetWidth(), o.GetHeight()); return v; case Origin.BOTTOM_LEFT: v.Set(0.0f, 0.0f); return v; case Origin.BOTTOM_RIGHT: v.Set(o.GetWidth(), 0.0f); return v; case Origin.LEFT_CENTER: v.Set(0.0f, o.GetHeight() / 2f); return v; case Origin.TOP_CENTER: v.Set(o.GetWidth() / 2f, o.GetHeight()); return v; case Origin.BOTTOM_CENTER: v.Set(o.GetWidth() / 2f, 0.0f); return v; case Origin.RIGHT_CENTER: v.Set(o.GetWidth(), o.GetHeight() / 2f); return v; default: return v; } }
public Line(Vector2f start_0, Vector2f end_1) : base() { this.loc = new Vector2f(0, 0); this.closest = new Vector2f(0, 0); this.type = Loon.Core.Geom.ShapeType.LINE_SHAPE; Set(start_0, end_1); }
public static LNJumpParabolaBy Action(float duration, Vector2f position, Vector2f refPoint) { LNJumpParabolaBy by = new LNJumpParabolaBy(); by._delta = position; by._duration = duration; by._refPoint = refPoint; return by; }
public static Vector2f CalculateVector(float angle, float magnitude) { Vector2f v = new Vector2f(); v.x = MathUtils.Sin(MathUtils.ToRadians(angle)); v.x *= magnitude; v.y = -MathUtils.Cos(MathUtils.ToRadians(angle)); v.y *= magnitude; return v; }
public static Vector2f GetVelocity(Vector2f velocity, List<Vector2f> forces) { foreach (Vector2f v in forces) { velocity.Add(v); } return velocity; }
new public static LNMoveBy Action(float duration, Vector2f pos) { LNMoveBy by = new LNMoveBy(); by._diff = pos; by._duration = duration; by._lastTime = 0f; return by; }
public static LNJumpBy Action(float duration, Vector2f delta, float height, int jumps) { LNJumpBy by = new LNJumpBy(); by._duration = duration; by._delta = delta; by._height = height; by._jumps = jumps; return by; }
new public static LNJumpTo Action(float duration, Vector2f delta, float height, int jumps) { LNJumpTo to = new LNJumpTo(); to._duration = duration; to._delta = delta; to._height = height; to._jumps = jumps; return to; }
public PPolygon(Vector2f[] vertices) { numVertices = vertices.Length; xs = new float[numVertices]; ys = new float[numVertices]; for (int i = 0; i < numVertices; i++) { xs[i] = vertices[i].x; ys[i] = vertices[i].y; } }
public Vector2f GetOrigin(string text) { Vector2f result = (Vector2f)CollectionUtils.Get(fontSizes, text); if (result == null) { result = new Vector2f(StringWidth(text) / 2f, GetHeight() / 2f); } return result; }
public static float AngleTo(Vector2f vectorA) { float angle = MathUtils.Atan2(vectorA.y, vectorA.x) * MathUtils.RAD_TO_DEG; if (angle < 0) { angle += 360; } return angle; }
public static Vector2f Cpy(Vector2f vectorA) { Vector2f newSVector2 = new Vector2f(); newSVector2.x = vectorA.x; newSVector2.y = vectorA.y; return newSVector2; }
public PPhysWorld() { this.iterations = 10; this.gravity = new Vector2f(0.0F, 9.80665F); this.bodies = new PBody[1024]; this.joints = new PJoint[1024]; this.shapes = new PShape[1024]; this.solvers = new PSolver[1024]; this.sap = new PSweepAndPrune(); }
public void Draw(int idx, SpriteBatch batch, Vector2f absPos, float rotation, Vector2f scale, LColor color) { RectBox rect = this._rectList[idx]; batch.SetColor(color); batch.Draw(_texture, absPos.x, absPos.y, anchor.x, anchor.y, rect.width, rect.height, scale.x, scale.y, MathUtils.ToDegrees(rotation), rect.x, rect.y, rect.width, rect.height, false, false); batch.ResetColor(); }
public PDragJoint(PBody b_0, float px, float py) { this.b = b_0; dragPoint = new Vector2f(px, py); localAnchor = new Vector2f(px - b_0.pos.x, py - b_0.pos.y); b_0.mAng.Transpose().MulEqual(localAnchor); anchor = b_0.mAng.Mul(localAnchor); anchor.AddLocal(b_0.pos); type = Physics.PJointType.DRAG_JOINT; mass = new PTransformer(); }
internal DefImage(string uid, string name, Vector2f p, Vector2f o, Vector2f a, Vector2f pl) { this.uniqueID = uid; this.pos = p; this.orig = o; this.anchor = a; this.place = pl; this.fileName = name; LNDataCache.SetImage(this, this.uniqueID); }
public static Vector2f RotateVector(Vector2f v, Vector2f center, float angle) { Vector2f result = new Vector2f(); float x = v.x - center.x; float y = v.y - center.y; result.x = MathUtils.Cos(angle) * x - MathUtils.Sin(angle) * y + center.x; result.y = MathUtils.Sin(angle) * x + MathUtils.Cos(angle) * y + center.y; return result; }
public Print(string context, LFont f, Vector2f v, int w, int h) { this.SetMessage(context, f); this.vector = v; this.width = w; this.height = h; this.wait = 0; this.isWait = false; }
public Print(string context, LFont font, Vector2f vector, int width, int height) { this.messageBuffer = new StringBuilder(messageLength); this.SetMessage(context, font); this.vector = vector; this.width = width; this.height = height; this.wait = 0; this.isWait = false; }
public float Distance(Vector2f point) { return(MathUtils.Sqrt(DistanceSquared(point))); }
public static float Area(Vector2f a, Vector2f b, Vector2f c) { return(Area(a.x, a.y, b.x, b.y, c.x, c.y)); }
public bool On(Vector2f point) { GetClosestPoint(point, closest); return(point.Equals(closest)); }