| /******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Pierre Allard, |
| * Regent L'Archeveque - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.addons.telecoms.impl; |
| |
| public class SimpleRectangularFrustumRadiationPatternCustomImpl extends SimpleRectangularFrustumRadiationPatternImpl { |
| |
| protected double maxGain = Double.NaN; |
| |
| @Override |
| public void setHorizontalFieldOfView(double newHorizontalFieldOfView) { |
| super.setHorizontalFieldOfView(newHorizontalFieldOfView); |
| this.maxGain = computeMaximumGain(); |
| } |
| |
| @Override |
| public void setVerticalFieldOfView(double newVerticalFieldOfView) { |
| super.setVerticalFieldOfView(newVerticalFieldOfView); |
| this.maxGain = computeMaximumGain(); |
| } |
| |
| @Override |
| public double computeGain(double theta, double phi) { |
| double x = Math.sin(theta) * Math.cos(phi); |
| double y = Math.sin(theta) * Math.sin(phi); |
| double z = Math.cos(theta); |
| |
| double azimuth = Math.abs(Math.atan2(y, z)); |
| double elevation = Math.abs(Math.atan2(x, z)); |
| |
| // Checks to see if the direction falls inside the cone. |
| if (azimuth <= (getHorizontalFieldOfView() / 2.0)) { |
| if (elevation <= (getVerticalFieldOfView() / 2.0)) { |
| return getMaxGain(); |
| } |
| } |
| |
| return Double.NEGATIVE_INFINITY; |
| } |
| |
| private double getMaxGain() { |
| if (Double.isNaN(this.maxGain)) { |
| this.maxGain = computeMaximumGain(); |
| } |
| |
| return this.maxGain; |
| } |
| |
| private double computeMaximumGain() { |
| double frustrumSolidAngle = 4.0 |
| * Math.asin((Math.sin(getHorizontalFieldOfView() / 2.0) * Math.sin(getVerticalFieldOfView() / 2.0))); |
| double apertureRatio = 4 * Math.PI / frustrumSolidAngle; |
| |
| double gain = 10.0 * Math.log10(apertureRatio); |
| return gain; |
| } |
| |
| } // SimpleRectangularFrustumRadiationPatternImpl |