本文整理汇总了Java中com.badlogic.gdx.math.GeometryUtils类的典型用法代码示例。如果您正苦于以下问题:Java GeometryUtils类的具体用法?Java GeometryUtils怎么用?Java GeometryUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeometryUtils类属于com.badlogic.gdx.math包,在下文中一共展示了GeometryUtils类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ensureClockWise
import com.badlogic.gdx.math.GeometryUtils; //导入依赖的package包/类
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;
}
}
示例4: 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;
}
示例5: 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;
}