Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Vector3
- {
- class Vector3
- {
- public double X { get; set; }
- public double Y { get; set; }
- public double Z { get; set; }
- public Vector3 (double x, double y, double z)
- {
- X = x;
- Y = y;
- Z = z;
- }
- public static Vector3 operator +(Vector3 a, Vector3 b)
- {
- return new Vector3(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
- }
- public static Vector3 operator -(Vector3 a, Vector3 b)
- {
- return new Vector3(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
- }
- public static Vector3 operator --(Vector3 a)
- {
- return new Vector3(a.X * (-1), a.Y * (-1), a.Z * (-1));
- }
- public static Vector3 operator *(Vector3 a, double number)
- {
- return new Vector3(a.X * number, a.Y * number, a.Z * number);
- }
- public static Vector3 operator /(Vector3 a, double number)
- {
- return new Vector3(a.X / number, a.Y / number, a.Z / number);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Vector3 star = new Vector3(7, 8, -1);
- Vector3 neutron_star = new Vector3(12, 1, 5);
- Vector3 result_star = star + neutron_star;
- Vector3 result_star2 = star - neutron_star;
- Vector3 result_star3 = --star;
- Vector3 result_star4 = star * 4;
- Vector3 result_star5 = neutron_star / 4;
- Console.WriteLine(result_star.X);
- Console.WriteLine(result_star.Y);
- Console.WriteLine(result_star.Z);
- Console.WriteLine("-----------STAR 2----------");
- Console.WriteLine(result_star2.X);
- Console.WriteLine(result_star2.Y);
- Console.WriteLine(result_star2.Z);
- Console.WriteLine("-----------STAR 3----------");
- Console.WriteLine(result_star3.X);
- Console.WriteLine(result_star3.Y);
- Console.WriteLine(result_star3.Z);
- Console.WriteLine("-----------STAR 4----------");
- Console.WriteLine(result_star4.X);
- Console.WriteLine(result_star4.Y);
- Console.WriteLine(result_star4.Z);
- Console.WriteLine("-----------STAR 5----------");
- Console.WriteLine(result_star5.X);
- Console.WriteLine(result_star5.Y);
- Console.WriteLine(result_star5.Z);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement