本文整理汇总了Java中com.flowpowered.math.TrigMath类的典型用法代码示例。如果您正苦于以下问题:Java TrigMath类的具体用法?Java TrigMath怎么用?Java TrigMath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TrigMath类属于com.flowpowered.math包,在下文中一共展示了TrigMath类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: eulerRad
import com.flowpowered.math.TrigMath; //导入依赖的package包/类
public static Quaterniond eulerRad(Vector3d vector3d) {
//https://gist.github.com/aeroson/043001ca12fe29ee911e
double yaw = vector3d.getX();
double pitch = vector3d.getY();
double roll = vector3d.getZ();
double rollOver2 = roll * 0.5f;
double sinRollOver2 = TrigMath.sin(rollOver2);
double cosRollOver2 = TrigMath.cos(rollOver2);
double pitchOver2 = pitch * 0.5f;
double sinPitchOver2 = TrigMath.sin(pitchOver2);
double cosPitchOver2 = TrigMath.cos(pitchOver2);
double yawOver2 = yaw * 0.5f;
double sinYawOver2 = TrigMath.sin(yawOver2);
double cosYawOver2 = TrigMath.cos(yawOver2);
return new Quaterniond(
cosYawOver2 * cosPitchOver2 * cosRollOver2 + sinYawOver2 * sinPitchOver2 * sinRollOver2,
cosYawOver2 * cosPitchOver2 * sinRollOver2 - sinYawOver2 * sinPitchOver2 * cosRollOver2,
cosYawOver2 * sinPitchOver2 * cosRollOver2 + sinYawOver2 * cosPitchOver2 * sinRollOver2,
sinYawOver2 * cosPitchOver2 * cosRollOver2 - cosYawOver2 * sinPitchOver2 * sinRollOver2
);
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:23,代码来源:VectorUtils.java
示例2: spiral
import com.flowpowered.math.TrigMath; //导入依赖的package包/类
@Override
public void spiral(double radius, double points, double fullrot,
double rotation,
Consumer<Vector3d> cb) {
double a = radius / points;
double s = fullrot / points;
double arad = s * TrigMath.TWO_PI;
rotation *= TrigMath.TWO_PI; //torad
for (double i = 1; i <= points; i++) {
double dist = i * a;
double angle = i * arad + rotation;
double x = TrigMath.cos(angle) * dist;
double y = TrigMath.sin(angle) * dist;
cb.accept(new Vector3d(x, 0, y));
}
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:17,代码来源:ParticleDecorator.java
示例3: rotateAroundAxisX
import com.flowpowered.math.TrigMath; //导入依赖的package包/类
public static Vector3d rotateAroundAxisX(Vector3d v, double angle) {
double sin = TrigMath.sin(angle);
double cos = TrigMath.cos(angle);
double y = v.getY() * cos - v.getZ() * sin;
double z = v.getY() * sin + v.getZ() * cos;
return new Vector3d(v.getX(), y, z);
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:8,代码来源:VectorUtils.java
示例4: rotateAroundAxisZ
import com.flowpowered.math.TrigMath; //导入依赖的package包/类
public static Vector3d rotateAroundAxisZ(Vector3d v, double angle) {
double cos = TrigMath.cos(angle);
double sin = TrigMath.sin(angle);
double x = v.getX() * cos - v.getY() * sin;
double y = v.getX() * sin + v.getY() * cos;
return new Vector3d(x, y, v.getZ());
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:8,代码来源:VectorUtils.java
示例5: rotateAroundAxisY
import com.flowpowered.math.TrigMath; //导入依赖的package包/类
public static Vector3d rotateAroundAxisY(Vector3d v, double angle) {
double cos = TrigMath.cos(angle);
double sin = TrigMath.sin(angle);
double z = v.getX() * -sin + v.getZ() * cos;
double x = v.getX() * cos + v.getZ() * sin;
return new Vector3d(x, v.getY(), z);
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:8,代码来源:VectorUtils.java
示例6: dropItem
import com.flowpowered.math.TrigMath; //导入依赖的package包/类
public static void dropItem(Player p, ItemStack itemStack) {
Entity optional = p.getLocation().getExtent()
.createEntity(EntityTypes.ITEM, p.getLocation()
.getPosition()
.add(TrigMath.cos((p.getRotation().getX() - 90) % 360) * 0.2, 1,
TrigMath.sin((p.getRotation().getX() - 90) % 360) * 0.2));
Vector3d rotation = p.getRotation();
Vector3d direction = Quaterniond.fromAxesAnglesDeg(rotation.getX(), -rotation.getY(), rotation.getZ()).getDirection();
Item item = (Item) optional;
item.offer(Keys.VELOCITY, direction.mul(0.33));
item.offer(Keys.REPRESENTED_ITEM, itemStack.createSnapshot());
item.offer(Keys.PICKUP_DELAY, 50);
p.getLocation().getExtent().spawnEntity(item);
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:16,代码来源:ItemStackUtils.java
示例7: circle
import com.flowpowered.math.TrigMath; //导入依赖的package包/类
@Override
public void circle(Location location, int count, double radius, Consumer<Location> callback) {
Extent e = location.getExtent();
double increment = TrigMath.TWO_PI / count;
for (int i = 0; i < count; i++) {
double angle = i * increment;
double x = location.getX() + radius * TrigMath.cos(angle);
double z = location.getZ() + radius * TrigMath.sin(angle);
callback.accept(new Location(e, x, location.getY(), z));
}
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:12,代码来源:ParticleDecorator.java
示例8: ellipse
import com.flowpowered.math.TrigMath; //导入依赖的package包/类
@Override
public void ellipse(Vector3d[] vector3ds, double a, double b, double vecmult, Vector3d rotationAngle) {
double increment = TrigMath.TWO_PI / vector3ds.length;
for (int i = 0; i < vector3ds.length; i++) {
double angle = i * increment;
Vector3d v = new Vector3d(a * TrigMath.cos(angle), b * TrigMath.sin(angle), 0).mul(vecmult);
vector3ds[i] = VectorUtils.rotateAroundAxisY(v, -rotationAngle.getY());
}
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:12,代码来源:ParticleDecorator.java
示例9: fillCircle
import com.flowpowered.math.TrigMath; //导入依赖的package包/类
public void fillCircle(Vector3d[] d, double radius) {
double increment = TrigMath.TWO_PI / d.length;
for (int i = 0; i < d.length; i++) {
double angle = i * increment;
double x = radius * TrigMath.cos(angle);
double z = radius * TrigMath.sin(angle);
d[i] = new Vector3d(x, 0, z);
}
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:10,代码来源:ParticleDecorator.java
示例10: computeRotatedPoints
import com.flowpowered.math.TrigMath; //导入依赖的package包/类
private static PointSet.Four<Vector2d> computeRotatedPoints(double width, double height, double radians) {
Vector2d bottomLeft = Vector2d.ZERO;
Vector2d bottomRight = new Vector2d(width, 0);
Vector2d topRight = new Vector2d(width, height);
Vector2d topLeft = new Vector2d(0, height);
double sin = TrigMath.sin(radians);
double cos = TrigMath.cos(radians);
bottomLeft = Maths.rotate(bottomLeft, sin, cos);
bottomRight = Maths.rotate(bottomRight, sin, cos);
topRight = Maths.rotate(topRight, sin, cos);
topLeft = Maths.rotate(topLeft, sin, cos);
return PointSet.Four.create(bottomLeft, bottomRight, topRight, topLeft);
}
开发者ID:TechShroom,项目名称:EmergencyLanding,代码行数:14,代码来源:Rectangle.java
示例11: toRad
import com.flowpowered.math.TrigMath; //导入依赖的package包/类
public static Vector3d toRad(Vector3d vector3d) {
return new Vector3d(vector3d.getX() * TrigMath.DEG_TO_RAD, vector3d.getY() * TrigMath.DEG_TO_RAD, vector3d.getZ() * TrigMath.DEG_TO_RAD);
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:4,代码来源:VectorUtils.java
注:本文中的com.flowpowered.math.TrigMath类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论