public static Angle3d operator +(Angle3d a1, Angle3d a2) { Angle3d angle = new Angle3d(); angle.X = a1.X + a2.X; angle.Y = a1.Y + a2.Y; angle.Z = a1.Z + a2.Z; return angle; }
public static Angle3d operator +(Angle3d a1, Angle3d a2) { Angle3d angle = new Angle3d(); angle.X = a1.X + a2.X; angle.Y = a1.Y + a2.Y; angle.Z = a1.Z + a2.Z; return(angle); }
/// <summary> /// Осуществляет поворот объекта вокруг оси на заданный угол. /// </summary> /// <param name="axis">Оси, вокруг которых осуществляется поворот.</param> /// <param name="angle">Угол, на который нужно повернуть объект.</param> /// <param name="type">Тип задания угла: абсолютно (перекрытие значений) или относительно (сложение значений).</param> public virtual void Turn(Point3d axis, Double angle, PositionType type = PositionType.Absolute) { Angle3d relative = new Angle3d(); if (type == PositionType.Relative) relative = new Angle3d(this.Angle); if (axis.X > 0) this.Angle.X = angle + relative.X; if (axis.Y > 0) this.Angle.Y = angle + relative.Y; if (axis.Z > 0) this.Angle.Z = angle + relative.Z; }
public static Point3d Rotate(Point3d vector, Angle3d angle) { Matrix vectorColumn = new Matrix(3, 1); vectorColumn[0, 0] = vector.X; vectorColumn[1, 0] = vector.Y; vectorColumn[2, 0] = vector.Z; Matrix rotationMatrix = new Matrix(3, 3); if (angle.X != 0) { rotationMatrix[0, 0] = 1; rotationMatrix[1, 1] = rotationMatrix[2, 2] = Math.Cos(Angle3d.DegreeToRadian(angle.X)); rotationMatrix[1, 2] = -Math.Sin(Angle3d.DegreeToRadian(angle.X)); rotationMatrix[2, 1] = -rotationMatrix[1, 2]; vectorColumn = rotationMatrix * vectorColumn; rotationMatrix.Clear(); } if (angle.Y != 0) { rotationMatrix[0, 0] = rotationMatrix[2, 2] = Math.Cos(Angle3d.DegreeToRadian(angle.Y)); rotationMatrix[0, 2] = Math.Sin(Angle3d.DegreeToRadian(angle.Y)); rotationMatrix[1, 1] = 1; rotationMatrix[2, 0] = -rotationMatrix[0, 2]; vectorColumn = rotationMatrix * vectorColumn; rotationMatrix.Clear(); } if (angle.Z != 0) { rotationMatrix[0, 0] = rotationMatrix[1, 1] = Math.Cos(Angle3d.DegreeToRadian(angle.Z)); rotationMatrix[2, 2] = 1; rotationMatrix[1, 0] = Math.Sin(Angle3d.DegreeToRadian(angle.Z)); rotationMatrix[0, 1] = -rotationMatrix[1, 0]; vectorColumn = rotationMatrix * vectorColumn; } Point3d result = new Point3d(vectorColumn[0, 0], vectorColumn[1, 0], vectorColumn[2, 0]); return(result); }
public static Point3d Rotate(Point3d vector, Angle3d angle) { Matrix vectorColumn = new Matrix(3, 1); vectorColumn[0, 0] = vector.X; vectorColumn[1, 0] = vector.Y; vectorColumn[2, 0] = vector.Z; Matrix rotationMatrix = new Matrix(3, 3); if (angle.X != 0) { rotationMatrix[0, 0] = 1; rotationMatrix[1, 1] = rotationMatrix[2, 2] = Math.Cos(Angle3d.DegreeToRadian(angle.X)); rotationMatrix[1, 2] = -Math.Sin(Angle3d.DegreeToRadian(angle.X)); rotationMatrix[2, 1] = -rotationMatrix[1, 2]; vectorColumn = rotationMatrix * vectorColumn; rotationMatrix.Clear(); } if (angle.Y != 0) { rotationMatrix[0, 0] = rotationMatrix[2, 2] = Math.Cos(Angle3d.DegreeToRadian(angle.Y)); rotationMatrix[0, 2] = Math.Sin(Angle3d.DegreeToRadian(angle.Y)); rotationMatrix[1, 1] = 1; rotationMatrix[2, 0] = -rotationMatrix[0, 2]; vectorColumn = rotationMatrix * vectorColumn; rotationMatrix.Clear(); } if (angle.Z != 0) { rotationMatrix[0, 0] = rotationMatrix[1, 1] = Math.Cos(Angle3d.DegreeToRadian(angle.Z)); rotationMatrix[2, 2] = 1; rotationMatrix[1, 0] = Math.Sin(Angle3d.DegreeToRadian(angle.Z)); rotationMatrix[0, 1] = -rotationMatrix[1, 0]; vectorColumn = rotationMatrix * vectorColumn; } Point3d result = new Point3d(vectorColumn[0, 0], vectorColumn[1, 0], vectorColumn[2, 0]); return result; }
public Angle3d(Angle3d basement) { this.X = basement.X; this.Y = basement.Y; this.Z = basement.Z; }
public override void Turn(Point3d axis, double angle, PositionType type = PositionType.Absolute) { base.Turn(axis, angle, type); Angle3d angle3d = new Angle3d(axis.X * angle, axis.Y * angle, axis.Z * angle); foreach (var obj in this.FixtureObjects) { Point3d result = DataService.Rotate(obj.Position, angle3d); if (obj is Fixture) ((Fixture)obj).SetPosition(result); else obj.Position = result; } }
/// <summary> /// Передвигает объект с заданной скоростью. /// </summary> public void Move() { Angle3d angle = new Angle3d(this.Angle.X, this.Angle.Y, this.Angle.Z); Point3d vector = DataService.Rotate(new Point3d(0, 0, this.Speed), angle); this.Position += vector; }