public Vec2 Reflect(Vec2 normal, float bounciness) { var vectorPartLength = Dot(normal); var projectedVector = normal.Clone().Scale(vectorPartLength); return(Subtract(projectedVector.Scale(1 + bounciness))); }
private void CreateLines() { _lineVecs = new[] { new Vec2(-105, 20), new Vec2(-70, 10), new Vec2(-40, 5), new Vec2(0, 5), new Vec2(40, 5), new Vec2(70, 10), new Vec2(105, 20) }; _lines = new LineSegment[_lineVecs.Length - 1]; for (var i = 0; i < _lines.Length; i++) { _lines[i] = new LineSegment(_position.Clone().Add(_lineVecs[i]), _position.Clone().Add(_lineVecs[i + 1]), 0x0000FF00); _level.AddChild(_lines[i]); } }
protected override void RenderSelf(GLContext glContext) { if (_startPoint == null || _vector == null) { return; } var endPoint = _startPoint.Clone().Add(_vector.Clone().Scale(Scale)); LineSegment.RenderLine(_startPoint, endPoint, Color, LineWidth, true); var smallVec = endPoint.Clone().Subtract(_startPoint).Normalize().Scale(-10); var left = new Vec2(-smallVec.y, smallVec.x); var 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 Reflect(Vec2 normal, float bounciness) { var vectorPartLength = Dot(normal); var projectedVector = normal.Clone().Scale(vectorPartLength); return Subtract(projectedVector.Scale(1 + bounciness)); }