本文整理汇总了C++中Sin函数的典型用法代码示例。如果您正苦于以下问题:C++ Sin函数的具体用法?C++ Sin怎么用?C++ Sin使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetHP
//陰陽「太極図」
int CBossChenMiddle::Taikyoku()
{
flag = 1;
deffence = 1;
SetHP(2000);
SetTime(40);
Suspend(60);
for( int i = 0; i < 60; ++i ) {
x += ( 450 - GetX() ) / 60;
y += ( GAME_CENTER_Y - GetY() ) / 60;
mt.Suspend(1);
}
CTamaTaikyoku tama;
tama.x = GetX();
tama.y = GetY();
tama.type = 12;
tama.v = 3;
int offset = 0.0;
while(1) {
for( int i = 0;; i++) {
//攻撃
tama.color = 1;
tama.a = offset;
g_lTama.Add( tama.Copy() );
tama.color = 0;
tama.a = offset + 180;
g_lTama.Add( tama.Copy() );
g_pMaterial->sndFire.Play(0);
double m;
if( GetDifficult() == DIFF_LUNATIC )
m = 1.5*(4-GetDifficult());
else
m = 2.0*(4-GetDifficult());
if( i > 120/m )
offset += 3.0*m*Sin((double)i*2);
this->Suspend(m);
}
}
return 1;
}
示例2: create_sloping_cylinder
void create_sloping_cylinder(GLfloat* matrix)
{
// GLfloat h = 2.03125;
// GLfloat length = 1;
glLoadIdentity();
// setEye();
glLoadMatrixf(matrix);
int th2, ph2, i, j, k;
double height=0.5;
double radius=0.40710678118;
glBegin(GL_QUAD_STRIP);
for (j=0;j<=360;j+=DEF_D)
{
// glColor3f(0,1,0);
if(j>=90 && j<=270)
{
glNormal3f(-Cos(j),0,-Sin(j));
glVertex3f((radius)*Cos(j),0,(radius)*Sin(j));
glVertex3f((radius)*Cos(j),-2*height,(radius)*Sin(j));
}
else
{
glNormal3f(-Cos(j),0,-Sin(j));
glVertex3f((radius)*Cos(j),-2*height+1-Cos(j)*2*height,(radius)*Sin(j));
glVertex3f((radius)*Cos(j),-2*height,(radius)*Sin(j));
}
}
glEnd();
glBegin(GL_QUAD_STRIP);
for (k=0;k<=360;k+=DEF_D)
{
glNormal3f(0,-1,0);
glVertex3f((radius)*Cos(k),-2*height,(radius)*Sin(k));
glNormal3f(0,-1,0);
glVertex3f((radius-0.0625)*Cos(k),-2*height,(radius-0.0625)*Sin(k));
}
glEnd();
}
示例3: Cos
Matrix4 &Matrix4::FromRotationZ(float angle)
{
// NOTE. The (x,y,z) coordinate system is assumed to be right-handed.
// Coordinate axis rotation matrices are of the form
// RZ = cos(t) -sin(t) 0
// sin(t) cos(t) 0
// 0 0 1
// where t > 0 indicates a counterclockwise rotation in the xy-plane.
float fCos = Cos(angle);
float fSin = Sin(angle);
m[0][0] = fCos; m[0][1] = -fSin; m[0][2] = 0.0f; m[0][3] = 0.0f;
m[1][0] = fSin; m[1][1] = fCos; m[1][2] = 0.0f; m[1][3] = 0.0f;
m[2][0] = 0.0f; m[2][1] = 0.0f; m[2][2] = 1.0f; m[2][3] = 0.0f;
m[3][0] = 0.0f; m[3][1] = 0.0f; m[3][2] = 0.0f; m[3][3] = 1.0f;
return *this;
}
示例4: DrawShots
// Iterate through the list of active shots and draw them
void DrawShots(void)
{
for( int i=0; i<UsedShots; i++ )
{
int x0, y0, x1, y1;
int d0 = Shots[i].dist;
int d1 = d0 + ShotLen;
int a = Shots[i].ang << 7;
int cs = -Cos(a), sn = Sin(a);
x0 = ((sn * d0) + 32768) / 65536 + HCenter;
y0 = ((cs * d0) + 32768) / 65536 + VCenter;
x1 = ((sn * d1) + 32768) / 65536 + HCenter;
y1 = ((cs * d1) + 32768) / 65536 + VCenter;
line( x0, y0, x1, y1, 1 );
}
}
示例5: rotate
void
rotate(obj *p, double phi, obj *q)
/* double phi; in radians */
{
register double x, y;
double M[6];
M[3] = M[0] = Cos(phi);
M[2] = -(M[1] = Sin(phi));
if (q == NULL)
M[4] = M[5] = 0;
else {
x = Xformx(q, 1, q->o_x, q->o_y);
y = Xformy(q, 0, q->o_x, q->o_y);
M[4] = (1 - M[0]) * x + M[1] * y;
M[5] = (1 - M[0]) * y - M[1] * x;
}
apply(p, M, 1);
}
示例6: Vector3
void DebugRenderer::AddCircle(const Vector3& center, const Vector3& normal, float radius, const Color& color, int steps, bool depthTest)
{
Quaternion orientation;
orientation.FromRotationTo(Vector3::UP, normal.Normalized());
Vector3 p = orientation * Vector3(radius, 0, 0) + center;
unsigned uintColor = color.ToUInt();
for(int i = 1; i <= steps; ++i)
{
const float angle = (float)i / (float)steps * 360.0f;
Vector3 v(radius * Cos(angle), 0, radius * Sin(angle));
Vector3 c = orientation * v + center;
AddLine(p, c, uintColor, depthTest);
p = c;
}
p = center + normal * (radius / 4.0f);
AddLine(center, p, uintColor, depthTest);
}
示例7: Sin
//----------------------------------------------------------------//
void MOAIDraw::DrawEllipseOutline ( float x, float y, float xRad, float yRad, u32 steps ) {
MOAIGfxDevice& gfxDevice = MOAIGfxDevice::Get ();
float angle = ( float )TWOPI / ( float )steps;
float angleStep = ( float )PI;
gfxDevice.BeginPrim ( GL_LINE_LOOP );
for ( u32 i = 0; i < steps; ++i, angleStep += angle ) {
gfxDevice.WriteVtx (
x + ( Sin ( angleStep ) * xRad ),
y + ( Cos ( angleStep ) * yRad ),
0.0f
);
gfxDevice.WriteFinalColor4b ();
}
gfxDevice.EndPrim ();
}
示例8: FxMoveToTimer
func FxMoveToTimer(object target, proplist fx, int time)
{
if(!master)
{
KillBall();
return;
}
if(GetEffect("Blocked", this))
{
ox=GetX();
oy=GetY();
return;
}
DrawParticleLine("Flash", 0, 0, ox-GetX(), oy-GetY(), 1, 0, 0, 15, movetrailparticles);
if(time%7 == 0)
{
for(var i = 0; i < 360; i+=5)
{
CreateParticle("Flash", Sin(i, 3), -Cos(i, 5), 0, 0, 10, moveparticle2, 2);
}
}
MoveToPos(fx.x, fx.y);
ox=GetX();
oy=GetY();
var dst = Distance(GetX(), GetY(), fx.x, fx.y);
if(dst < 5)
{
SetXDir(0);
SetYDir(0);
CheckForEnemies(AttackSize);
Idle();
CreateParticle("StarSpark", 0, 0, 0, 0, 10, moveparticle, 5);
return -1;
}
}
示例9: Radians
//
// RotationAroundAxis
//
void Mat4::RotationAroundAxis( const Vec3<float>& Axis, float Angle )
{
// x^2 + (1 - x^2) * cos(a) => x^2 + cos(a) - x^2 * cos(a) =>
// x^2 * (1 - cos(a)) + cos(a)
#ifdef _DEBUG
Axis.Assume();
#endif
float Rad = Radians( Angle );
float s = Sin( Rad );
float c = Cos( Rad );
float d = 1.0f - c;
float xs = Axis.x * s;
float ys = Axis.y * s;
float zs = Axis.z * s;
float xyd = Axis.x * Axis.y * d;
float xzd = Axis.x * Axis.z * d;
float yzd = Axis.y * Axis.z * d;
m[ 0 ].x = Axis.x * Axis.x * d + c;
m[ 0 ].y = xyd + zs;
m[ 0 ].z = xzd - ys;
m[ 0 ].w = 0.0f;
m[ 1 ].x = xyd - zs;
m[ 1 ].y = Axis.y * Axis.y * d + c;
m[ 1 ].z = yzd + xs;
m[ 1 ].w = 0.0f;
m[ 2 ].x = xzd + ys;
m[ 2 ].y = yzd - xs;
m[ 2 ].z = Axis.z * Axis.z * d + c;
m[ 2 ].w = 0.0f;
m[ 3 ].x = 0.0f;
m[ 3 ].y = 0.0f;
m[ 3 ].z = 0.0f;
m[ 3 ].w = 1.0f;
}
示例10: STATICHASH
void LineBatcher::DrawEllipsoid(const Vector& Center, const Vector& Extents,
unsigned int Color) {
#if BUILD_RELEASE
if (m_IsDebug) {
return;
}
#endif
STATICHASH(DebugSphereResolution);
uint Resolution = ConfigManager::GetInt(sDebugSphereResolution, 16);
uint TwoR = Resolution * 2;
m_AddPositions.Resize(Resolution * 3);
m_AddColors.Resize(Resolution * 3);
m_AddIndices.Resize(Resolution * 6);
for (uint i = 0; i < Resolution * 3; ++i) {
m_AddColors[i] = Color;
}
float Mult = TWOPI / (float)Resolution;
for (uint i = 0; i < Resolution; ++i) {
float u = Cos((float)i * Mult);
float v = Sin((float)i * Mult);
m_AddPositions[i] =
Vector(Center.x + u * Extents.x, Center.y + v * Extents.y, Center.z);
m_AddPositions[i + Resolution] =
Vector(Center.x + u * Extents.x, Center.y, Center.z + v * Extents.z);
m_AddPositions[i + TwoR] =
Vector(Center.x, Center.y + u * Extents.y, Center.z + v * Extents.z);
m_AddIndices[i * 2] = (index_t)(i);
m_AddIndices[i * 2 + 1] = (index_t)((i + 1) % Resolution);
m_AddIndices[i * 2 + TwoR] = (index_t)(i + Resolution);
m_AddIndices[i * 2 + TwoR + 1] =
(index_t)(((i + 1) % Resolution) + Resolution);
m_AddIndices[i * 2 + TwoR * 2] = (index_t)(i + TwoR);
m_AddIndices[i * 2 + TwoR * 2 + 1] =
(index_t)(((i + 1) % Resolution) + TwoR);
}
Add(m_AddPositions, m_AddColors, m_AddIndices);
}
示例11: FoxLi
void FoxLi( Matrix<Complex<Real>>& A, Int n, Real omega )
{
DEBUG_CSE
typedef Complex<Real> C;
const Real pi = 4*Atan( Real(1) );
const C phi = Sqrt( C(0,omega/pi) );
// Compute Gauss quadrature points and weights
Matrix<Real> d, e;
Zeros( d, n, 1 );
e.Resize( n-1, 1 );
for( Int j=0; j<n-1; ++j )
{
const Real betaInv = 2*Sqrt(1-Pow(j+Real(1),-2)/4);
e(j) = 1/betaInv;
}
Matrix<Real> x, Z;
HermitianTridiagEig( d, e, x, Z, UNSORTED );
auto z = Z( IR(0), ALL );
Matrix<Real> sqrtWeights( z ), sqrtWeightsTrans;
for( Int j=0; j<n; ++j )
sqrtWeights(0,j) = Sqrt(Real(2))*Abs(sqrtWeights(0,j));
herm_eig::Sort( x, sqrtWeights, ASCENDING );
Transpose( sqrtWeights, sqrtWeightsTrans );
// Form the integral operator
A.Resize( n, n );
for( Int j=0; j<n; ++j )
{
for( Int i=0; i<n; ++i )
{
const Real theta = -omega*Pow(x(i)-x(j),2);
const Real realPart = Cos(theta);
const Real imagPart = Sin(theta);
A(i,j) = phi*C(realPart,imagPart);
}
}
// Apply the weighting
DiagonalScale( LEFT, NORMAL, sqrtWeightsTrans, A );
DiagonalScale( RIGHT, NORMAL, sqrtWeightsTrans, A );
}
示例12: XInput
void Player::update(Game* game) {
frameCount++;
auto pad = XInput(0);
pad.setLeftThumbDeadZone();
pad.setRightThumbDeadZone();
//move
if (!Vec2(pad.leftThumbX, pad.leftThumbY).isZero) {
rad = Atan2(-pad.leftThumbY, pad.leftThumbX);
pos += Vec2(Cos(rad), Sin(rad)) * 7.5;
}
pos = Vec2(Clamp(pos.x, 0.0, static_cast<double>(Game::stageSize.x)), Clamp(pos.y, 0.0, static_cast<double>(Game::stageSize.y)));
//bomb
if (Input::KeyX.clicked) {
game->getBulletManager()->clear();
game->getEnemyManager()->clear();
}
//fire
if (!Vec2(pad.rightThumbX, pad.rightThumbY).isZero) {
for (int i : {-1, 1, 0}) {
const double fireRad = Atan2(-pad.rightThumbY, pad.rightThumbX) + Radians(5 * i);
if (fireCount % 5 == 0) {
auto shot = std::make_shared<NormalShot>(pos, fireRad);
shotManager->add(shot);
}
}
}
fireCount++;
shotManager->update(game);
tracks.push_front(pos);
if (tracks.size() > 20) tracks.pop_back();
damageCount++;
checkBulletHit(game);
if (frameCount % 10 == 0 && damageCount) shield++;
shield = Clamp(shield, 0, SHIELD_MAX);
hp = Clamp(hp, 0, HP_MAX);
}
示例13: partinit
////////////////////////////////////////////////////////////////////////////////
// Initialize individual particles
void partinit(particle *part, int i) {
float v = rand()%1000; // Velocity
float th = rand()%360; // Angle
part[i].active = true; // Make ALL the particles active
part[i].life = 1.0; // Give ALL the particles full life
part[i].fade = frand(100, 0.003); // Random Fade Speed
/*part[i].r = red; // Red Color
part[i].g = green; // Green Color
part[i].b = blue; // Blue Color
*/part[i].xp = 0.0; // Center
part[i].yp = 0.0; // Oscilating
part[i].zp = 0.0; // Center
part[i].xd = Sin(th) * v; // X Speed;
part[i].yd = v; //frand(50, -25) * v; // Y Speed;
part[i].zd = Cos(th) * v; // Z Speed;
part[i].xg = 0; // No X-Axis pull
part[i].yg = -10; // Vertical pull down
part[i].zg = 0; // No Z-Axis pull
}
示例14: Cos
//----------------------------------------------------------------//
int MOAIVectorUtil::StrokeWedge ( const MOAIVectorStyle& style, ZLVec2D*& verts, const ZLVec2D& origin, const ZLVec2D& n0, const ZLVec2D& n1, float width ) {
float wedge = n0.Radians ( n1 ); // angle between two normals
u32 steps = style.GetResolutionForWedge ( wedge );
if ( verts ) {
float angle = n0.Radians (); // angle of first normal against x axis
float angleStep = wedge / ( float )steps;
for ( u32 i = 0; i <= steps; ++i, angle += angleStep ) {
ZLVec2D v;
v.mX = origin.mX + ( Cos ( angle ) * width );
v.mY = origin.mY + ( Sin ( angle ) * width );
*( verts++ ) = v;
}
}
return ( int )( steps + 1 );
}
示例15: sub_80CA8B4
static void sub_80CA8B4(struct Sprite* sprite)
{
if (TranslateAnimSpriteByDeltas(sprite))
{
DestroySprite(sprite);
}
else
{
if (sprite->data[5] > 0x7F)
{
sprite->subpriority = sub_8079E90(gAnimBankTarget) + 1;
}
else
{
sprite->subpriority = sub_8079E90(gAnimBankTarget) + 6;
}
sprite->pos2.x += Sin(sprite->data[5], 5);
sprite->pos2.y += Cos(sprite->data[5], 14);
sprite->data[5] = (sprite->data[5] + 15) & 0xFF;
}
}