Java 类com.badlogic.gdx.math.GeometryUtils 实例源码

项目:NoRiskNoFun    文件:GameScene.java   
/**
 * 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;
}
项目:fabulae    文件:TrapOriginator.java   
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);
}
项目:bladecoder-adventure-engine    文件:PolygonUtils.java   
static public void ensureClockWise (float[] polygon, int offset, int count) {
    if (GeometryUtils.isClockwise(polygon, offset, count)) return;
    int lastX = offset + count - 2;
    for (int i = offset, n = offset + count / 2; i < n; i += 2) {
        int other = lastX - i;
        float x = polygon[i];
        float y = polygon[i + 1];
        polygon[i] = polygon[other];
        polygon[i + 1] = polygon[other + 1];
        polygon[other] = x;
        polygon[other + 1] = y;
    }
}
项目:mini2Dx    文件:Polygon.java   
@Override
public float getCenterX() {
    if(centroidDirty) {
        GeometryUtils.polygonCentroid(vertices, 0, vertices.length, centroid);
        centroidDirty = false;
    }
    return centroid.x;
}
项目:mini2Dx    文件:Polygon.java   
@Override
public float getCenterY() {
    if(centroidDirty) {
        GeometryUtils.polygonCentroid(vertices, 0, vertices.length, centroid);
        centroidDirty = false;
    }
    return centroid.y;
}