Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Vector3
  8. {
  9.     class Vector3
  10.     {
  11.         public double X { get; set; }
  12.         public double Y { get; set; }
  13.         public double Z { get; set; }
  14.  
  15.         public Vector3 (double x, double y, double z)
  16.         {
  17.             X = x;
  18.             Y = y;
  19.             Z = z;
  20.         }
  21.  
  22.         public static Vector3 operator +(Vector3 a, Vector3 b)
  23.         {
  24.             return new Vector3(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
  25.         }
  26.  
  27.         public static Vector3 operator -(Vector3 a, Vector3 b)
  28.         {
  29.             return new Vector3(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
  30.         }
  31.  
  32.         public static Vector3 operator --(Vector3 a)
  33.         {
  34.             return new Vector3(a.X * (-1), a.Y * (-1), a.Z * (-1));
  35.         }
  36.  
  37.         public static Vector3 operator *(Vector3 a, double number)
  38.         {
  39.             return new Vector3(a.X * number, a.Y * number, a.Z * number);
  40.         }
  41.  
  42.         public static Vector3 operator /(Vector3 a, double number)
  43.         {
  44.             return new Vector3(a.X / number, a.Y / number, a.Z / number);
  45.         }
  46.     }
  47.     class Program
  48.     {
  49.         static void Main(string[] args)
  50.         {
  51.             Vector3 star = new Vector3(7, 8, -1);
  52.             Vector3 neutron_star = new Vector3(12, 1, 5);
  53.  
  54.             Vector3 result_star = star + neutron_star;
  55.             Vector3 result_star2 = star - neutron_star;
  56.             Vector3 result_star3 = --star;
  57.             Vector3 result_star4 = star * 4;
  58.             Vector3 result_star5 = neutron_star / 4;
  59.  
  60.             Console.WriteLine(result_star.X);
  61.             Console.WriteLine(result_star.Y);
  62.             Console.WriteLine(result_star.Z);
  63.             Console.WriteLine("-----------STAR 2----------");
  64.             Console.WriteLine(result_star2.X);
  65.             Console.WriteLine(result_star2.Y);
  66.             Console.WriteLine(result_star2.Z);
  67.             Console.WriteLine("-----------STAR 3----------");
  68.             Console.WriteLine(result_star3.X);
  69.             Console.WriteLine(result_star3.Y);
  70.             Console.WriteLine(result_star3.Z);
  71.             Console.WriteLine("-----------STAR 4----------");
  72.             Console.WriteLine(result_star4.X);
  73.             Console.WriteLine(result_star4.Y);
  74.             Console.WriteLine(result_star4.Z);
  75.             Console.WriteLine("-----------STAR 5----------");
  76.             Console.WriteLine(result_star5.X);
  77.             Console.WriteLine(result_star5.Y);
  78.             Console.WriteLine(result_star5.Z);
  79.  
  80.             Console.ReadKey();
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement