using UnityEngine;
using System;

namespace Starstrider42.CustomAsteroids {
	/// <summary>Standard implementation of <see cref="ReferencePlane"/>.</summary>
	internal class SimplePlane : ReferencePlane {
		public string name { get; private set; }

		/// <summary>Rotation used to implement toDefaultFrame.</summary>
		private readonly Quaternion xform;

		/// <summary>
		/// Creates a new ReferencePlane with the given name and rotation.
		/// </summary>
		/// <param name="id">A unique identifier for this object. Initialises the <see cref="name"/> property.</param>
		/// <param name="thisToDefault">A rotation that transforms vectors from this reference frame 
		/// to the KSP default reference frame.</param>
		internal SimplePlane(string id, Quaternion thisToDefault) {
			this.name = id;
			this.xform = thisToDefault;
		}

		public Vector3d toDefaultFrame(Vector3d inFrame) {
			Quaternion frameCorrection = Planetarium.Rotation;
			return frameCorrection * xform * Quaternion.Inverse(frameCorrection) * inFrame;
		}
	}
}

using UnityEngine;

namespace Starstrider42.CustomAsteroids {
	/// <summary>Standard implementation of <see cref="ReferencePlane"/>.</summary>
	internal class SimplePlane : ReferencePlane {
		public string name { get; private set; }

		/// <summary>Rotation used to implement toDefaultFrame.</summary>
		private readonly Quaternion xform;

		/// <summary>
		/// Creates a new ReferencePlane with the given name and rotation.
		/// </summary>
		/// <param name="id">A unique identifier for this object. Initialises the <see cref="name"/> property.</param>
		/// <param name="thisToDefault">A rotation that transforms vectors from this reference frame 
		/// to the KSP default reference frame.</param>
		internal SimplePlane(string id, Quaternion thisToDefault) {
			this.name = id;
			this.xform = thisToDefault;
		}

		public Vector3d toDefaultFrame(Vector3d inFrame) {
			Quaternion frameCorrection = Planetarium.Zup.Rotation;
			return Quaternion.Inverse(frameCorrection) * xform * frameCorrection * inFrame;
		}
	}
}

Fix reference plane rotation bug.
Fix reference plane rotation bug.

Fixes a regression of #26 caused by the API changes in KSP 1.2.
