org.bukkit.util.Vector.crossProduct()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(77)

本文整理了Java中org.bukkit.util.Vector.crossProduct()方法的一些代码示例,展示了Vector.crossProduct()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.crossProduct()方法的具体详情如下:
包路径:org.bukkit.util.Vector
类名称:Vector
方法名:crossProduct

Vector.crossProduct介绍

[英]Calculates the cross product of this vector with another. The cross product is defined as:

  • x = y1 * z2 - y2 * z1
  • y = z1 * x2 - z2 * x1
  • z = x1 * y2 - x2 * y1
    [中]计算此向量与另一个向量的叉积。叉积的定义如下:
    x=y1z2-y2z1
    y=z1x2-z2
    x1
    z=x1y2-x2*y1

代码示例

代码示例来源:origin: ProjectKorra/ProjectKorra

public static Vector rotateVectorAroundVector(final Vector axis, final Vector rotator, final double degrees) {
  final double angle = Math.toRadians(degrees);
  Vector rotation = axis.clone();
  final Vector rotate = rotator.clone();
  rotation = rotation.normalize();
  final Vector thirdaxis = rotation.crossProduct(rotate).normalize().multiply(rotate.length());
  return rotate.multiply(Math.cos(angle)).add(thirdaxis.multiply(Math.sin(angle)));
}

代码示例来源:origin: ProjectKorra/ProjectKorra

public static double getDistanceFromLine(final Vector line, final Location pointonline, final Location point) {
  final Vector AP = new Vector();
  double Ax, Ay, Az;
  Ax = pointonline.getX();
  Ay = pointonline.getY();
  Az = pointonline.getZ();
  double Px, Py, Pz;
  Px = point.getX();
  Py = point.getY();
  Pz = point.getZ();
  AP.setX(Px - Ax);
  AP.setY(Py - Ay);
  AP.setZ(Pz - Az);
  return (AP.crossProduct(line).length()) / (line.length());
}

代码示例来源:origin: NoCheatPlus/NoCheatPlus

final double distance = blockEyes.crossProduct(context.direction).length() / context.lengthDirection;
context.minViolation = Math.min(context.minViolation, distance);
cancel = true;

代码示例来源:origin: elBukkit/MagicPlugin

if (aim.getY() > 0.7) {
  Vector axis = new Vector(1, 0, 0);
  Vector perp = aim.clone().crossProduct(axis).multiply(dr);
} else if (aim.getX() > 0.7) {
  Vector axis = new Vector(0, 1, 0);
  Vector perp = aim.clone().crossProduct(axis).multiply(dr);
} else {
  Vector axis = new Vector(0, 1, 0);
  Vector perp = aim.clone().crossProduct(axis).multiply(dr);

代码示例来源:origin: elBukkit/MagicPlugin

Vector perp = new Vector();
perp.copy(direction);
perp.crossProduct(up);

代码示例来源:origin: NoCheatPlus/NoCheatPlus

final double distance = blockEyes.crossProduct(direction).length() / direction.length();

相关文章