public static Vec2 GetUnitVectorDegrees(float degrees) { Vec2 vectorDegrees = new Vec2(); vectorDegrees.x = Mathf.Cos(degrees); vectorDegrees.y = Mathf.Sin(degrees); return vectorDegrees; }
public LineSegment (Vec2 pStart, Vec2 pEnd, uint pColor = 0xffffffff, uint pLineWidth = 1, bool pGlobalCoords = false) { start = pStart; end = pEnd; color = pColor; lineWidth = pLineWidth; useGlobalCoords = pGlobalCoords; }
public Arrow (Vec2 pStartPoint, Vec2 pVector, float pScale, uint pColor = 0xffffffff, uint pLineWidth = 1) { _startPoint = pStartPoint; _vector = pVector; scale = pScale; color = pColor; lineWidth = pLineWidth; }
public Player(Vec2 pPosition = null) : base("colors.png") { SetOrigin(width / 2, height / 2); position = pPosition; velocity = Vec2.zero; acceleration = Vec2.zero; x = position.x; y = position.y; }
protected override void RenderSelf (GXPEngine.Core.GLContext glContext) { if (_startPoint == null || _vector == null) return; Vec2 endPoint = _startPoint.Clone().Add (_vector.Clone().Scale (scale)); LineSegment.RenderLine (_startPoint, endPoint, color, lineWidth, true); Vec2 smallVec = endPoint.Clone().Sub(_startPoint).Normalize ().Scale (-10); Vec2 left = new Vec2 (-smallVec.y, smallVec.x); Vec2 right = new Vec2 (smallVec.y, -smallVec.x); left.Add (smallVec).Add (endPoint); right.Add (smallVec).Add (endPoint); LineSegment.RenderLine (endPoint, left, color, lineWidth, true); LineSegment.RenderLine (endPoint, right, color, lineWidth, true); }
public Vec2 Substract(Vec2 other) { x -= other.x; y -= other.y; return this; }
public Vec2 SetXY(Vec2 other) { x = other.x; y = other.y; return this; }
public Vec2 RotateAroundRadians(float radians, Vec2 p) { x -= p.x; y -= p.y; RotateRadians(radians); x += p.x; y += p.y; return this; }
public float Dot(Vec2 other) { float dot = x * other.x + y * other.y; return(dot); }
public Vec2 Clone() { Vec2 clone = new Vec2(x, y); return(clone); }
public Vec2 Clone() { Vec2 clone = new Vec2(x, y); return clone; }
public Vec2 Reflect(Vec2 pNormal, float pBounciness = 1) { Sub(pNormal.Scale((1 + pBounciness) * Dot(pNormal))); return this; }
public float Dot(Vec2 vec) { float dot = x * vec.x + y * vec.y; return dot; }
public Vec2 Normal() { Vec2 unitNormal = new Vec2(-y, x); unitNormal.Normalize(); return unitNormal; }
public Vec2 RotateAroundRadians(Vec2 rotatingAround, float radians) { x -= rotatingAround.x; y -= rotatingAround.y; float positionX; float positionY; positionX = x * Mathf.Cos(radians) - y * Mathf.Sin(radians); positionY = x * Mathf.Sin(radians) + y * Mathf.Cos(radians); x = positionX + rotatingAround.x; y = positionY + rotatingAround.y; return this; }
public Vec2 SetXY(Vec2 other) { x = other.x; y = other.y; return(this); }
public static Vec2 GetUnitVectorDegrees(float degrees) { Vec2 vec2 = new Vec2(Mathf.Cos(Deg2Rad(degrees)), Mathf.Sin(Deg2Rad(degrees))); return vec2; }
public Vec2 Add(Vec2 other) { x += other.x; y += other.y; return(this); }
public Vec2 Add(Vec2 other) { x += other.x; y += other.y; return this; }
public NLineSegment (Vec2 pStart, Vec2 pEnd, uint pColor = 0xffffffff, uint pLineWidth = 1, bool pGlobalCoords = false) : base (pStart, pEnd, pColor, pLineWidth, pGlobalCoords) { _normal = new Arrow (null, null, 40, 0xfffff000, 1); AddChild (_normal); }
public float Dot(Vec2 other) { float dot = x * other.x + y * other.y; return dot; }
public Vec2 Subtract(Vec2 other) { x -= other.x; y -= other.y; return(this); }
static public void RenderLine (Vec2 pStart, Vec2 pEnd, uint pColor = 0xffffffff, uint pLineWidth = 1, bool pGlobalCoords = false) { RenderLine (pStart.x, pStart.y, pEnd.x, pEnd.y, pColor, pLineWidth, pGlobalCoords); }
public static Vec2 GetUnitVectorRadians(float radians) { Vec2 vectorRadians = new Vec2(); return vectorRadians; }
public Vec2 Reflect(Vec2 pNormal, float pBounciness = 1) { pNormal = Normal(); x = this.x -((1 + pBounciness) * (Dot(pNormal) * pNormal.x)); y = this.y -((1 + pBounciness) * (Dot(pNormal) * pNormal.y)); return this; }
public Vec2 RotateAroundDegrees(float degrees, Vec2 p) { x -= p.x; y -= p.y; RotateDegrees(degrees); x += p.x; y += p.y; return this; }
void Update() { _armVector = new Vec2(Input.mouseX - _player.x, Input.mouseY - _player.y).Normalize().Multiply(this.height * 1.5f); RotateArm(); }
public static Vec2 GetUnitVectorDegrees(float degrees) { Vec2 vec2 = new Vec2(Mathf.Cos(Deg2Rad(degrees)), Mathf.Sin(Deg2Rad(degrees))); return(vec2); }