/*
 * JaamSim Discrete Event Simulation
 * Copyright (C) 2012 Ausenco Engineering Canada Inc.
 * Copyright (C) 2019-2020 JaamSim Software Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jaamsim.controllers;

import com.jaamsim.math.Vec3d;

public class PolarInfo {

	double rotZ; // The spherical coordinate that rotates around Z (in radians)
	double rotX; // Ditto for X
	double radius; // The distance the camera is from the view center
	final Vec3d viewCenter;

	PolarInfo(Vec3d center) {
		viewCenter = new Vec3d(center);
	}

	@Override
	public boolean equals(Object o) {
		if (!(o instanceof PolarInfo)) {
			return false;
		}
		PolarInfo pi = (PolarInfo)o;

		return pi.rotZ == rotZ && pi.rotX == rotX && pi.radius == radius &&
		       viewCenter.equals3(pi.viewCenter);
	}

}

@@ -987,16 +987,57 @@
 wCenter;
+ // centre of the polar coordinate system
 %0A%0A%09Polar
@@ -1095,16 +1095,585 @@
 r);%0A%09%7D%0A%0A
+%09/**%0A%09 * Constructs the polar coordinates for the view camera.%0A%09 * @param center - position along the camera's line of sight%0A%09 * @param pos - position of the view camera%0A%09 */%0A%09PolarInfo(Vec3d center, Vec3d pos) %7B%0A%09%09viewCenter = new Vec3d(center);%0A%0A%09%09Vec3d viewDiff = new Vec3d();%0A%09%09viewDiff.sub3(pos, center);%0A%09%09radius = viewDiff.mag3();%0A%0A%09%09rotZ = Math.atan2(viewDiff.x, -viewDiff.y);%0A%09%09if (viewDiff.x == 0.0d && viewDiff.y == 0.0d)  // degenerate case%0A%09%09%09rotZ = 0.0d;%0A%0A%09%09double xyDist = Math.hypot(viewDiff.x, viewDiff.y);%0A%09%09rotX = Math.atan2(xyDist, viewDiff.z);%0A%09%7D%0A%0A
 %09@Overri

add constructor for PolarInfo