using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using OpenTK;

namespace ObjectManager
{
    public class ObjectManager
    {
        public enum Axis
        {
            X,
            Y,
            Z
        }

        public static void Rotate(ref List<Vertex> Vertices, Axis RotationAxis, double RotationAngle)
        {
            double cosa = Math.Cos(RotationAngle * 0.017453292519943);
            double sina = Math.Sin(RotationAngle * 0.017453292519943);
            double oc = 1.0 - cosa;
            for (int i = 0; i < Vertices.Count; i++)
            {
                double x = Vertices[i].Coordinates.X, y = Vertices[i].Coordinates.Y, z = Vertices[i].Coordinates.Z;
                //ObjectManager.Vertex v = Vertices[i];
                switch (RotationAxis)
                {
                    case Axis.X:
                        y = cosa * Vertices[i].Coordinates.Y - sina * Vertices[i].Coordinates.Z;
                        z = cosa * Vertices[i].Coordinates.Z + sina * Vertices[i].Coordinates.Y;
                        break;
                    case Axis.Y:
                        x = cosa * Vertices[i].Coordinates.X + sina * Vertices[i].Coordinates.Z;
                        z = cosa * Vertices[i].Coordinates.Z - sina * Vertices[i].Coordinates.X;
                        break;
                    case Axis.Z:
                        x = cosa * Vertices[i].Coordinates.X - sina * Vertices[i].Coordinates.Y;
                        y = cosa * Vertices[i].Coordinates.Y + sina * Vertices[i].Coordinates.X;
                        break;
                }
                Vertices[i].Coordinates.X = x;
                Vertices[i].Coordinates.Y = y;
                Vertices[i].Coordinates.Z = z;
            }
        }

        public static void Translate(ref List<Vertex> Vertices, Vector3d Translation)
        {
            for (int i = 0; i < Vertices.Count; i++)
            {
                Vertices[i].Coordinates.X += Translation.X;
                Vertices[i].Coordinates.Y += Translation.Y;
                Vertices[i].Coordinates.Z += Translation.Z;
            }
        }
    }
}
