// 直行座標から極座標に変換. void CEphemeris::ConvertRectangularToPolar( const izanagi::math::SVector4& ortho, SPolarCoord& polar) { polar.longitude = izanagi::math::CMath::ArcTan2F(ortho.z, ortho.x); IZ_FLOAT sinLong = izanagi::math::CMath::SinF(polar.longitude); if (sinLong != 0.0f) { IZ_FLOAT z = ortho.z / sinLong; polar.latitude = izanagi::math::CMath::ArcTan2F(ortho.y, z); } else { IZ_FLOAT cosLong = izanagi::math::CMath::CosF(polar.longitude); IZ_FLOAT x = ortho.x / cosLong; polar.latitude = izanagi::math::CMath::ArcTan2F(ortho.y, x); } if (ortho.y != 0.0f) { IZ_FLOAT sinLat = izanagi::math::CMath::SinF(polar.latitude); polar.radius = ortho.y / sinLat; } else { IZ_FLOAT cosLat = izanagi::math::CMath::CosF(polar.latitude); if (ortho.z != 0.0f) { polar.radius = ortho.z / (cosLat * sinLong); } else { IZ_FLOAT cosLong = izanagi::math::CMath::CosF(polar.longitude); polar.radius = ortho.x / (cosLat * cosLong); } } polar.latitude = IZ_RAD2DEG(polar.latitude); polar.longitude = IZ_RAD2DEG(polar.longitude); }
IZ_BOOL CBillboardYAxis::Render( izanagi::graph::CGraphicsDevice* device, izanagi::sample::CSampleCamera& camera) { izanagi::math::SMatrix44 mtx; izanagi::math::SMatrix44::SetUnit(mtx); izanagi::math::SMatrix44::RotByX(mtx, mtx, IZ_DEG2RAD(-90.0f)); izanagi::math::SVector4 dir = camera.GetDir(); if (dir.x == 0.0f) { } else { IZ_FLOAT deg = IZ_RAD2DEG(::atan2(dir.z, dir.x)); izanagi::math::SMatrix44::RotByY(mtx, mtx, -1.0f * IZ_DEG2RAD(deg) + IZ_MATH_PI1_2); } m_Shader->Begin(device, 0, IZ_FALSE); { if (m_Shader->BeginPass(0)) { _SetShaderParam( m_Shader, "g_mL2W", (void*)&mtx, sizeof(mtx)); _SetShaderParam( m_Shader, "g_mW2C", (void*)&camera.GetParam().mtxW2C, sizeof(camera.GetParam().mtxW2C)); // シェーダ設定 m_Shader->CommitChanges(device); m_Rect->Draw(device); } } m_Shader->End(device); return IZ_TRUE; }