本文整理汇总了Java中com.o3dr.services.android.lib.util.MathUtils.simplify方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.simplify方法的具体用法?Java MathUtils.simplify怎么用?Java MathUtils.simplify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.o3dr.services.android.lib.util.MathUtils
的用法示例。
在下文中一共展示了MathUtils.simplify方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onGestureEnded
import com.o3dr.services.android.lib.util.MathUtils; //导入方法依赖的package包/类
@Override
public void onGestureEnded(GestureOverlayView arg0, MotionEvent arg1) {
overlay.setEnabled(false);
List<LatLong> path = decodeGesture();
if (path.size() > 1) {
path = MathUtils.simplify(path, toleranceInPixels);
}
listener.onPathFinished(path);
}
示例2: onGestureEnded
import com.o3dr.services.android.lib.util.MathUtils; //导入方法依赖的package包/类
@Override
public void onGestureEnded(GestureOverlayView arg0, MotionEvent arg1) {
view.setEnabled(false);
List<LatLong> path = decodeGesture();
if (path.size() > 1) {
path = MathUtils.simplify(path, toleranceInPixels);
}
listener.onPathFinished(path);
}
示例3: exportPathAsMissionItems
import com.o3dr.services.android.lib.util.MathUtils; //导入方法依赖的package包/类
/**
* Export the given path as a Mission
* @param pathPoints
* @return
*/
public static List<MissionItem> exportPathAsMissionItems(List<? extends LatLongAlt> pathPoints, double toleranceInPixels) {
List<MissionItem> exportedMissionItems = new LinkedList<>();
if(pathPoints != null && !pathPoints.isEmpty()) {
List<LatLong> simplifiedPath = MathUtils.simplify(pathPoints, toleranceInPixels);
int pointsCount = simplifiedPath.size();
if(pointsCount > 3){
// When taking off and/or landing the altitude has a tendency to be a bit too low.
LatLongAlt first = (LatLongAlt) simplifiedPath.get(0);
LatLongAlt second = (LatLongAlt) simplifiedPath.get(1);
first.setAltitude((second.getAltitude() + first.getAltitude())/ 2.0);
LatLongAlt beforeLast = (LatLongAlt) simplifiedPath.get(pointsCount - 2);
LatLongAlt last = (LatLongAlt) simplifiedPath.get(pointsCount -1);
last.setAltitude((last.getAltitude() + beforeLast.getAltitude())/2.0);
}
SpaceTime lastPoint = null;
for(LatLong point : simplifiedPath) {
if(point instanceof SpaceTime) {
SpaceTime currentPoint = (SpaceTime) point;
if(lastPoint != null) {
// Calculate the speed used by the vehicle from the last point to the
// current one.
double distanceInM = MathUtils.getDistance3D(lastPoint, currentPoint);
float deltaTimeInSecs = Math.abs(currentPoint.getTimeInMs()
- lastPoint.getTimeInMs()) / 1000F;
if (Float.compare(deltaTimeInSecs, 0f) != 0) {
double speed = distanceInM / deltaTimeInSecs;
ChangeSpeed speedMissionItem = new ChangeSpeed();
speedMissionItem.setSpeed(speed);
exportedMissionItems.add(speedMissionItem);
}
}
lastPoint = currentPoint;
}
else {
lastPoint = null;
}
SplineWaypoint waypoint = new SplineWaypoint();
waypoint.setCoordinate((LatLongAlt) point);
exportedMissionItems.add(waypoint);
}
}
return exportedMissionItems;
}