示例#1
0
文件: Extra.cs 项目: kuviman/csVPE
 /// <summary>
 /// Clamp the length of a vector.
 /// </summary>
 /// <param name="a">Vector to clamp.</param>
 /// <param name="maxlen">Maximal length.</param>
 /// <returns>Clamped vector.</returns>
 public static Vec2 Clamp(Vec2 a, double maxlen)
 {
     if (a.Length <= maxlen)
         return a;
     else
         return a.Unit * maxlen;
 }
示例#2
0
 /// <summary>
 /// Floor each component.
 /// </summary>
 public static Vec2i Floor(Vec2 v)
 {
     return new Vec2i(Floor(v.X), Floor(v.Y));
 }
示例#3
0
 /// <summary>
 /// Ceil each component.
 /// </summary>
 public static Vec2i Ceil(Vec2 v)
 {
     return new Vec2i(Ceil(v.X), Ceil(v.Y));
 }
示例#4
0
文件: Extra.cs 项目: kuviman/csVPE
 /// <summary>
 /// Multiply two vectors componentwise.
 /// </summary>
 /// <param name="a">First vector.</param>
 /// <param name="b">Second vector.</param>
 public static Vec2 CompMult(Vec2 a, Vec2 b)
 {
     return new Vec2(a.X * b.X, a.Y * b.Y);
 }
示例#5
0
文件: Extra.cs 项目: kuviman/csVPE
 /// <summary>
 /// Divide one vector by another componentwise.
 /// </summary>
 /// <param name="a">First vector.</param>
 /// <param name="b">Second vector.</param>
 public static Vec2 CompDiv(Vec2 a, Vec2 b)
 {
     return new Vec2(a.X / b.X, a.Y / b.Y);
 }
示例#6
0
文件: Extra.cs 项目: kuviman/csVPE
 /// <summary>
 /// Rotate a vector 90 degrees counter-clockwise.
 /// </summary>
 /// <param name="a">Vector to rotate.</param>
 public static Vec2 Rotate90(Vec2 a)
 {
     return new Vec2(-a.Y, a.X);
 }
示例#7
0
文件: Extra.cs 项目: kuviman/csVPE
 /// <summary>
 /// Rotate a vector.
 /// </summary>
 /// <param name="a">Vector to rotate.</param>
 /// <param name="angle">Ratation angle.</param>
 /// <returns>Rotated vector.</returns>
 public static Vec2 Rotate(Vec2 a, double angle)
 {
     double s = Math.Sin(angle);
     double c = Math.Cos(angle);
     return new Vec2(a.X * c - a.Y * s, a.X * s + a.Y * c);
 }
示例#8
0
文件: Algebra.cs 项目: kuviman/csVPE
 /// <summary>
 /// Get the skew product of two vectors.
 /// </summary>
 /// <param name="a">First vector.</param>
 /// <param name="b">Second vector.</param>
 /// <returns></returns>
 public static double Skew(Vec2 a, Vec2 b)
 {
     return a.X * b.Y - a.Y * b.X;
 }
示例#9
0
文件: Algebra.cs 项目: kuviman/csVPE
 /// <summary>
 /// Get the dot product of two vectors.
 /// </summary>
 /// <param name="a">First vector.</param>
 /// <param name="b">Second vector.</param>
 public static double Dot(Vec2 a, Vec2 b)
 {
     return a.X * b.X + a.Y * b.Y;
 }
示例#10
0
 public override void MouseMove(Vec2 position)
 {
     base.MouseMove(position);
     if (client.Player != null)
         client.Player.Get<PositionComponent>().Rotation = (Mouse.Position - new Vec2(App.Width, App.Height) / 2).Arg + camera.Rotation;
 }
示例#11
0
 public override void MouseDown(MouseButton button, Vec2 position)
 {
     base.MouseDown(button, position);
 }