| /******************************************************************************* |
| * 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.sensors.fov.impl; |
| |
| import org.eclipse.apogy.addons.sensors.fov.AngularSpan; |
| import org.eclipse.apogy.addons.sensors.fov.ApogyAddonsSensorsFOVFactory; |
| import org.eclipse.apogy.addons.sensors.fov.ApogyAddonsSensorsFOVPackage; |
| import org.eclipse.apogy.addons.sensors.fov.DistanceRange; |
| import org.eclipse.apogy.common.emf.transaction.ApogyCommonTransactionFacade; |
| |
| public class CircularSectorFieldOfViewCustomImpl extends CircularSectorFieldOfViewImpl { |
| |
| @Override |
| public AngularSpan getAngularSpan() { |
| AngularSpan tmp = super.getAngularSpan(); |
| |
| if (tmp == null) { |
| tmp = ApogyAddonsSensorsFOVFactory.eINSTANCE.createAngularSpan(); |
| ApogyCommonTransactionFacade.INSTANCE.basicSet(this, |
| ApogyAddonsSensorsFOVPackage.Literals.CIRCULAR_SECTOR_FIELD_OF_VIEW__ANGULAR_SPAN, tmp, true); |
| |
| } |
| |
| return tmp; |
| } |
| |
| @Override |
| public void setAngularSpan(AngularSpan newAngularSpan) { |
| super.setAngularSpan(newAngularSpan); |
| } |
| |
| @Override |
| public DistanceRange getRange() { |
| DistanceRange tmp = super.getRange(); |
| if (tmp == null) { |
| tmp = ApogyAddonsSensorsFOVFactory.eINSTANCE.createDistanceRange(); |
| ApogyCommonTransactionFacade.INSTANCE.basicSet(this, |
| ApogyAddonsSensorsFOVPackage.Literals.CIRCULAR_SECTOR_FIELD_OF_VIEW__RANGE, tmp, true); |
| } |
| |
| return tmp; |
| } |
| |
| @Override |
| public void setRange(DistanceRange newRange) { |
| super.setRange(newRange); |
| } |
| |
| @Override |
| public double getArea() { |
| double area = 0.0; |
| if ((getAngularSpan() != null) && (getRange() != null)) { |
| // Computes the area of the maximum radius sector. |
| double maxRadiusSectorArea = 0.5 * Math.pow(getRange().getMaximumDistance(), 2.0) |
| * getAngularSpan().getSpanningAngle(); |
| |
| // Computes the area of the minimum radius sector. |
| double minRadiusSectorArea = 0.5 * Math.pow(getRange().getMinimumDistance(), 2.0) |
| * getAngularSpan().getSpanningAngle(); |
| |
| // The field of view area is the difference between the two. |
| if (maxRadiusSectorArea > minRadiusSectorArea) { |
| area = maxRadiusSectorArea - minRadiusSectorArea; |
| } else { |
| area = 0.0; |
| } |
| } else { |
| area = 0.0; |
| } |
| |
| return area; |
| } |
| } // CircularSectorFieldOfViewImpl |