本文整理汇总了Java中android.util.FloatMath.cos方法的典型用法代码示例。如果您正苦于以下问题:Java FloatMath.cos方法的具体用法?Java FloatMath.cos怎么用?Java FloatMath.cos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.FloatMath
的用法示例。
在下文中一共展示了FloatMath.cos方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rotate
import android.util.FloatMath; //导入方法依赖的package包/类
/**
* Rotates p1 around p2 by angle degrees.
* @param p1
* @param p2
* @param angle
*/
public void rotate(PointF p1, PointF p2, float angle) {
float px = p1.x;
float py = p1.y;
float ox = p2.x;
float oy = p2.y;
p1.x = (FloatMath.cos(angle) * (px-ox) - FloatMath.sin(angle) * (py-oy) + ox);
p1.y = (FloatMath.sin(angle) * (px-ox) + FloatMath.cos(angle) * (py-oy) + oy);
}
示例2: rotate
import android.util.FloatMath; //导入方法依赖的package包/类
public Math_Vector rotate(float angle) {
float rad = angle * TO_RADIANS;
float cos = FloatMath.cos(rad);
float sin = FloatMath.sin(rad);
float newX = this.x * cos - this.y * sin;
float newY = this.x * sin + this.y * cos;
this.x = newX;
this.y = newY;
return this;
}
示例3: convertPitchAndYawToPosition
import android.util.FloatMath; //导入方法依赖的package包/类
/**calculate methods*/
protected PLPosition convertPitchAndYawToPosition(float pitch, float yaw)
{
float r = this.getZ(), pr = (90.0f - pitch) * PLConstants.kToRadians, yr = -yaw * PLConstants.kToRadians;
float x = r * FloatMath.sin(pr) * FloatMath.cos(yr);
float y = r * FloatMath.sin(pr) * FloatMath.sin(yr);
float z = r * FloatMath.cos(pr);
return PLPosition.PLPositionMake(y, z, x);
}
示例4: calculatePoints
import android.util.FloatMath; //导入方法依赖的package包/类
protected List<PLPosition> calculatePoints(GL10 gl)
{
List<PLPosition> result = new ArrayList<PLPosition>(4);
//1
PLPosition pos = this.convertPitchAndYawToPosition(mAtv, mAth), pos1 = this.convertPitchAndYawToPosition(mAtv + 0.0001f, mAth);
//2 and 3
PLVector3 p1 = new PLVector3(pos.x, pos.y, pos.z),
p2p1 = new PLVector3(0.0f, 0.0f, 0.0f).sub(p1),
r = p2p1.crossProduct(new PLVector3(pos1.x, pos1.y, pos1.z).sub(p1)),
s = p2p1.crossProduct(r);
//4
r.normalize();
s.normalize();
//5.1
float w = mWidth * PLConstants.kPanoramaRadius, h = mHeight * PLConstants.kPanoramaRadius;
float radius = FloatMath.sqrt((w * w) + (h * h));
//5.2
float angle = (float)Math.asin(h / radius);
//5.3
PLVector3 n = new PLVector3(0.0f, 0.0f, 0.0f);
for(float theta : new float[]{ PLConstants.kPI - angle, angle, PLConstants.kPI + angle, 2 * PLConstants.kPI - angle})
{
n.x = p1.x + (radius * FloatMath.cos(theta) * r.x) + (radius * FloatMath.sin(theta) * s.x);
n.y = p1.y + (radius * FloatMath.cos(theta) * r.y) + (radius * FloatMath.sin(theta) * s.y);
n.z = p1.z + (radius * FloatMath.cos(theta) * r.z) + (radius * FloatMath.sin(theta) * s.z);
n.normalize();
result.add(PLPosition.PLPositionMake(n.x, n.y, n.z));
}
return result;
}
示例5: drawArc
import android.util.FloatMath; //导入方法依赖的package包/类
private static void drawArc(Path p, float lastX, float lastY, float x, float y, float rx, float ry, float theta,
int largeArc, int sweepArc) {
// Log.d("drawArc", "from (" + lastX + "," + lastY + ") to (" + x + ","+ y + ") r=(" + rx + "," + ry +
// ") theta=" + theta + " flags="+ largeArc + "," + sweepArc);
// http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
if (rx == 0 || ry == 0) {
p.lineTo(x, y);
return;
}
if (x == lastX && y == lastY) {
return; // nothing to draw
}
rx = Math.abs(rx);
ry = Math.abs(ry);
final float thrad = theta * (float) Math.PI / 180;
final float st = FloatMath.sin(thrad);
final float ct = FloatMath.cos(thrad);
final float xc = (lastX - x) / 2;
final float yc = (lastY - y) / 2;
final float x1t = ct * xc + st * yc;
final float y1t = -st * xc + ct * yc;
final float x1ts = x1t * x1t;
final float y1ts = y1t * y1t;
float rxs = rx * rx;
float rys = ry * ry;
float lambda = (x1ts / rxs + y1ts / rys) * 1.001f; // add 0.1% to be sure that no out of range occurs due to
// limited precision
if (lambda > 1) {
float lambdasr = FloatMath.sqrt(lambda);
rx *= lambdasr;
ry *= lambdasr;
rxs = rx * rx;
rys = ry * ry;
}
final float R =
FloatMath.sqrt((rxs * rys - rxs * y1ts - rys * x1ts) / (rxs * y1ts + rys * x1ts))
* ((largeArc == sweepArc) ? -1 : 1);
final float cxt = R * rx * y1t / ry;
final float cyt = -R * ry * x1t / rx;
final float cx = ct * cxt - st * cyt + (lastX + x) / 2;
final float cy = st * cxt + ct * cyt + (lastY + y) / 2;
final float th1 = angle(1, 0, (x1t - cxt) / rx, (y1t - cyt) / ry);
float dth = angle((x1t - cxt) / rx, (y1t - cyt) / ry, (-x1t - cxt) / rx, (-y1t - cyt) / ry);
if (sweepArc == 0 && dth > 0) {
dth -= 360;
} else if (sweepArc != 0 && dth < 0) {
dth += 360;
}
// draw
if ((theta % 360) == 0) {
// no rotate and translate need
arcRectf.set(cx - rx, cy - ry, cx + rx, cy + ry);
p.arcTo(arcRectf, th1, dth);
} else {
// this is the hard and slow part :-)
arcRectf.set(-rx, -ry, rx, ry);
arcMatrix.reset();
arcMatrix.postRotate(theta);
arcMatrix.postTranslate(cx, cy);
arcMatrix.invert(arcMatrix2);
p.transform(arcMatrix2);
p.arcTo(arcRectf, th1, dth);
p.transform(arcMatrix);
}
}
示例6: calculateEndPoint
import android.util.FloatMath; //导入方法依赖的package包/类
public void calculateEndPoint() {
end.x = FloatMath.cos(angle) * length + start.x;
end.y = FloatMath.sin(angle) * length + start.y;
}
示例7: polar
import android.util.FloatMath; //导入方法依赖的package包/类
public PointF polar( float a, float l ) {
this.x = l * FloatMath.cos( a );
this.y = l * FloatMath.sin( a );
return this;
}
示例8: Flare
import android.util.FloatMath; //导入方法依赖的package包/类
@SuppressLint("FloatMath")
public Flare( int nRays, float radius ) {
super( 0, 0, 0, 0 );
int gradient[] = {0xFFFFFFFF, 0x00FFFFFF};
texture = new Gradient( gradient );
this.nRays = nRays;
angle = 45;
angularSpeed = 180;
vertices = ByteBuffer.
allocateDirect( (nRays * 2 + 1) * 4 * (Float.SIZE / 8) ).
order( ByteOrder.nativeOrder() ).
asFloatBuffer();
indices = ByteBuffer.
allocateDirect( nRays * 3 * Short.SIZE / 8 ).
order( ByteOrder.nativeOrder() ).
asShortBuffer();
float v[] = new float[4];
v[0] = 0;
v[1] = 0;
v[2] = 0.25f;
v[3] = 0;
vertices.put( v );
v[2] = 0.75f;
v[3] = 0;
for (int i=0; i < nRays; i++) {
float a = i * 3.1415926f * 2 / nRays;
v[0] = FloatMath.cos( a ) * radius;
v[1] = FloatMath.sin( a ) * radius;
vertices.put( v );
a += 3.1415926f * 2 / nRays / 2;
v[0] = FloatMath.cos( a ) * radius;
v[1] = FloatMath.sin( a ) * radius;
vertices.put( v );
indices.put( (short)0 );
indices.put( (short)(1 + i * 2) );
indices.put( (short)(2 + i * 2) );
}
indices.position( 0 );
}
示例9: drawSprite
import android.util.FloatMath; //导入方法依赖的package包/类
public void drawSprite(float draw_center_x, float draw_center_y,
float draw_width, float draw_height, float angle,
GL_TextureRegion region) {
float draw_halfWidth = draw_width / 2;
float draw_halfHeight = draw_height / 2;
float rad = angle * Math_Vector.TO_RADIANS; // �߽����� �������� ���� ������ ��
float cos = FloatMath.cos(rad);
float sin = FloatMath.sin(rad);
float draw_left_down_x = -draw_halfWidth * cos - (-draw_halfHeight)
* sin;
float draw_left_down_y = -draw_halfWidth * sin + (-draw_halfHeight)
* cos;
float draw_right_down_x = draw_halfWidth * cos - (-draw_halfHeight)
* sin;
float draw_right_down_y = draw_halfWidth * sin + (-draw_halfHeight)
* cos;
float draw_right_up_x = draw_halfWidth * cos - draw_halfHeight * sin;
float draw_right_up_y = draw_halfWidth * sin + draw_halfHeight * cos;
float draw_left_up_x = -draw_halfWidth * cos - draw_halfHeight * sin;
float draw_left_up_y = -draw_halfWidth * sin + draw_halfHeight * cos;
draw_left_down_x += draw_center_x;
draw_left_down_y += draw_center_y;
draw_right_down_x += draw_center_x;
draw_right_down_y += draw_center_y;
draw_right_up_x += draw_center_x;
draw_right_up_y += draw_center_y;
draw_left_up_x += draw_center_x;
draw_left_up_y += draw_center_y;
verticesBuffer[bufferIndex++] = draw_left_down_x;// x1;
verticesBuffer[bufferIndex++] = draw_left_down_y;// y1;
verticesBuffer[bufferIndex++] = region.text_l_u_p_x;
verticesBuffer[bufferIndex++] = region.text_r_d_p_y;
verticesBuffer[bufferIndex++] = draw_right_down_x;// x2;
verticesBuffer[bufferIndex++] = draw_right_down_y;// y2;
verticesBuffer[bufferIndex++] = region.text_r_d_p_x;
verticesBuffer[bufferIndex++] = region.text_r_d_p_y;
verticesBuffer[bufferIndex++] = draw_right_up_x;// x3;
verticesBuffer[bufferIndex++] = draw_right_up_y;// y3;
verticesBuffer[bufferIndex++] = region.text_r_d_p_x;
verticesBuffer[bufferIndex++] = region.text_l_u_p_y;
verticesBuffer[bufferIndex++] = draw_left_up_x;// x4;
verticesBuffer[bufferIndex++] = draw_left_up_y;// y4;
verticesBuffer[bufferIndex++] = region.text_l_u_p_x;
verticesBuffer[bufferIndex++] = region.text_l_u_p_y;
numSprites++;
}