本文整理了Java中pythagoras.f.Vector.set()
方法的一些代码示例,展示了Vector.set()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.set()
方法的具体详情如下:
包路径:pythagoras.f.Vector
类名称:Vector
方法名:set
[英]Sets all of the elements of the vector.
[中]设置向量的所有元素。
代码示例来源:origin: com.samskivert/pythagoras
/**
* Sets the ray parameters to the values contained in the supplied vectors.
*
* @return a reference to this ray, for chaining.
*/
public Ray2 set (IVector origin, IVector direction) {
this.origin.set(origin);
this.direction.set(direction);
return this;
}
代码示例来源:origin: com.samskivert/pythagoras
/**
* Transforms a vector as specified, storing the result in the vector provided.
* @return a reference to the result vector, for chaining.
*/
public static Vector transform (float x, float y, float sx, float sy, float sina, float cosa,
Vector result) {
return result.set((x*cosa - y*sina) * sx, (x*sina + y*cosa) * sy);
}
代码示例来源:origin: com.samskivert/pythagoras
/** Transforms a vector as specified (as a point, accounting for translation), storing the
* result in the vector provided.
* @return a reference to the result vector, for chaining. */
public static Vector transform (float x, float y, float sx, float sy, float sina, float cosa,
float tx, float ty, Vector result) {
return result.set((x*cosa - y*sina) * sx + tx, (x*sina + y*cosa) * sy + ty);
}
代码示例来源:origin: samskivert/pythagoras
/**
* Sets the ray parameters to the values contained in the supplied vectors.
*
* @return a reference to this ray, for chaining.
*/
public Ray2 set (IVector origin, IVector direction) {
this.origin.set(origin);
this.direction.set(direction);
return this;
}
代码示例来源:origin: com.samskivert/pythagoras
@Override // from IMatrix3
public Vector transformVector (IVector vector, Vector result) {
float vx = vector.x(), vy = vector.y();
return result.set(m00*vx + m10*vy, m01*vx + m11*vy);
}
代码示例来源:origin: com.samskivert/pythagoras
@Override // from Transform
public Vector transform (IVector v, Vector into) {
float x = v.x(), y = v.y();
return into.set(m00*x + m10*y, m01*x + m11*y);
}
代码示例来源:origin: com.samskivert/pythagoras
/** Copies the elements of another vector.
* @return a reference to this vector, for chaining. */
public Vector set (XY other) {
return set(other.x(), other.y());
}
代码示例来源:origin: com.samskivert/pythagoras
/**
* Inverse transforms a vector as specified, storing the result in the vector provided.
* @return a reference to the result vector, for chaining.
*/
public static Vector inverseTransform (float x, float y, float sx, float sy, float rotation,
Vector result) {
float sinnega = FloatMath.sin(-rotation), cosnega = FloatMath.cos(-rotation);
float nx = (x * cosnega - y * sinnega); // unrotate
float ny = (x * sinnega + y * cosnega);
return result.set(nx / sx, ny / sy); // unscale
}
代码示例来源:origin: com.samskivert/pythagoras
@Override // from IMatrix3
public Vector transformPoint (IVector point, Vector result) {
float px = point.x(), py = point.y();
return result.set(m00*px + m10*py + m20, m01*px + m11*py + m21);
}
代码示例来源:origin: com.samskivert/pythagoras
@Override // from Transform
public Vector inverseTransform (IVector v, Vector into) {
float x = v.x(), y = v.y();
float det = m00 * m11 - m01 * m10;
if (Math.abs(det) == 0f) {
// determinant is zero; matrix is not invertible
throw new NoninvertibleTransformException(this.toString());
}
float rdet = 1 / det;
return into.set((x * m11 - y * m10) * rdet,
(y * m00 - x * m01) * rdet);
}
代码示例来源:origin: samskivert/pythagoras
/**
* Sets this vector's angle, preserving its magnitude.
* @return a reference to this vector, for chaining.
*/
public Vector setAngle (float angle) {
float l = length();
return set(l * FloatMath.cos(angle), l * FloatMath.sin(angle));
}
代码示例来源:origin: com.samskivert/pythagoras
@Override // from interface IVector
public Vector rotate (float angle, Vector result) {
float x = x(), y = y();
float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle);
return result.set(x*cosa - y*sina, x*sina + y*cosa);
}
代码示例来源:origin: com.samskivert/pythagoras
@Override // from interface IVector
public Vector lerp (IVector other, float t, Vector result) {
float x = x(), y = y();
float dx = other.x() - x, dy = other.y() - y;
return result.set(x + t*dx, y + t*dy);
}
代码示例来源:origin: com.samskivert/pythagoras
@Override // from interface IVector
public Vector cross (IVector other, Vector result) {
float x = x(), y = y(), ox = other.x(), oy = other.y();
return result.set(y*ox - x*oy, x*oy - y*ox);
}
代码示例来源:origin: samskivert/pythagoras
@Override // from interface IVector
public Vector rotate (float angle, Vector result) {
float x = x(), y = y();
float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle);
return result.set(x*cosa - y*sina, x*sina + y*cosa);
}
代码示例来源:origin: threerings/playn
@Override
public Vector inverseTransform(IVector v, Vector into) {
float m00 = m00(), m01 = m01(), m10 = m10(), m11 = m11();
float x = v.x(), y = v.y();
float det = m00 * m11 - m01 * m10;
if (Math.abs(det) == 0f) {
// determinant is zero; matrix is not invertible
throw new NoninvertibleTransformException(this.toString());
}
float rdet = 1 / det;
return into.set((x * m11 - y * m10) * rdet, (y * m00 - x * m01) * rdet);
}
代码示例来源:origin: threerings/playn
@Override
public Vector transform(IVector v, Vector into) {
float x = v.x(), y = v.y();
return into.set(m00() * x + m10() * y, m01() * x + m11() * y);
}
代码示例来源:origin: com.samskivert/pythagoras
@Override // from interface IVector
public Vector rotateScaleAndAdd (float angle, float scale, IVector add, Vector result) {
float x = x(), y = y();
float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle);
return result.set((x*cosa - y*sina)*scale + add.x(),
(x*sina + y*cosa)*scale + add.y());
}
代码示例来源:origin: samskivert/pythagoras
@Override // from interface IVector
public Vector rotateScaleAndAdd (float angle, float scale, IVector add, Vector result) {
float x = x(), y = y();
float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle);
return result.set((x*cosa - y*sina)*scale + add.x(),
(x*sina + y*cosa)*scale + add.y());
}
代码示例来源:origin: threerings/playn
@Override
public Vector transformPoint (IVector v, Vector into) {
float x = v.x(), y = v.y();
return into.set(m00()*x + m10()*y + tx(), m01()*x + m11()*y + ty());
}
内容来源于网络,如有侵权,请联系作者删除!