本文整理汇总了Java中com.badlogic.gdx.math.GeometryUtils.polygonCentroid方法的典型用法代码示例。如果您正苦于以下问题:Java GeometryUtils.polygonCentroid方法的具体用法?Java GeometryUtils.polygonCentroid怎么用?Java GeometryUtils.polygonCentroid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.GeometryUtils
的用法示例。
在下文中一共展示了GeometryUtils.polygonCentroid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculatePolygonCentroid
import com.badlogic.gdx.math.GeometryUtils; //导入方法依赖的package包/类
/**
* Calculate the centroid of a polygon defined by its vertices
* @param vertices Array of polygon vertices
* @return Vector2 containing x and y coordinates of the centroid
*/
private Vector2 calculatePolygonCentroid(float[] vertices) {
Vector2 polygonCentroid = new Vector2();
GeometryUtils.polygonCentroid(vertices, 0, vertices.length, polygonCentroid);
return polygonCentroid;
}
示例2: TrapOriginator
import com.badlogic.gdx.math.GeometryUtils; //导入方法依赖的package包/类
public TrapOriginator(TrapLocation trapLocation, float[] vertices) {
this(trapLocation.getInternalId(), trapLocation.getTrap().getType().getName(), trapLocation.getMap(), trapLocation);
isTrapLocation = true;
Vector2 polygonCenter = GeometryUtils.polygonCentroid(vertices, 0, vertices.length, MathUtil.getVector2());
position().set(polygonCenter);
MathUtil.freeVector2(polygonCenter);
}
示例3: getCenterX
import com.badlogic.gdx.math.GeometryUtils; //导入方法依赖的package包/类
@Override
public float getCenterX() {
if(centroidDirty) {
GeometryUtils.polygonCentroid(vertices, 0, vertices.length, centroid);
centroidDirty = false;
}
return centroid.x;
}
示例4: getCenterY
import com.badlogic.gdx.math.GeometryUtils; //导入方法依赖的package包/类
@Override
public float getCenterY() {
if(centroidDirty) {
GeometryUtils.polygonCentroid(vertices, 0, vertices.length, centroid);
centroidDirty = false;
}
return centroid.y;
}