本文整理汇总了C++中AVector::Dot方法的典型用法代码示例。如果您正苦于以下问题:C++ AVector::Dot方法的具体用法?C++ AVector::Dot怎么用?C++ AVector::Dot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AVector
的用法示例。
在下文中一共展示了AVector::Dot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Orthonormalize
//----------------------------------------------------------------------------
void AVector::Orthonormalize (AVector& vec0, AVector& vec1, AVector& vec2)
{
// If the input vectors are v0, v1, and v2, then the Gram-Schmidt
// orthonormalization produces vectors u0, u1, and u2 as follows,
//
// u0 = v0/|v0|
// u1 = (v1-(u0*v1)u0)/|v1-(u0*v1)u0|
// u2 = (v2-(u0*v2)u0-(u1*v2)u1)/|v2-(u0*v2)u0-(u1*v2)u1|
//
// where |A| indicates length of vector A and A*B indicates dot
// product of vectors A and B.
// Compute u0.
vec0.Normalize();
// Compute u1.
float dot0 = vec0.Dot(vec1);
vec1 -= dot0*vec0;
vec1.Normalize();
// Compute u2.
float dot1 = vec1.Dot(vec2);
dot0 = vec0.Dot(vec2);
vec2 -= dot0*vec0 + dot1*vec1;
vec2.Normalize();
}
示例2: _RolateCamera
//----------------------------------------------------------------------------
void EditRenderView_Scene::_RolateCamera(float horz, float vert)
{
Scene *scene = PX2_PROJ.GetScene();
CameraActor *camActor = scene->GetUseCameraActor();
if (VT_PERSPECTIVE == mViewType)
{
AVector rVector;
AVector dVector;
AVector uVector;
camActor->GetRDUVector(rVector, dVector, uVector);
// horz
HMatrix incrH(AVector::UNIT_Z, -horz*0.5f);
dVector = incrH * dVector;
uVector = incrH * uVector;
rVector = incrH * rVector;
// vert
Matrix3f kIncrV(rVector, -vert*0.5f);
dVector = kIncrV * dVector;
uVector = kIncrV * uVector;
dVector.Normalize();
float dVectorAdj = dVector.Dot(AVector::UNIT_Z);
float dVectorAdj1 = dVector.Dot(-AVector::UNIT_Z);
if (dVectorAdj > 0.9f || dVectorAdj1 > 0.9f)
return;
AVector::Orthonormalize(dVector, uVector, rVector);
camActor->LocalTransform.SetRotate(HMatrix(rVector, dVector,
uVector, AVector::ZERO, true));
}
}
示例3: Normal
//----------------------------------------------------------------------------
AVector CurveSegment::Normal (float u) const
{
AVector velocity = PU(u);
AVector acceleration = PUU(u);
float VDotV = velocity.Dot(velocity);
float VDotA = velocity.Dot(acceleration);
AVector normal = VDotV*acceleration - VDotA*velocity;
normal.Normalize();
return normal;
}
示例4: GetFrame
//----------------------------------------------------------------------------
void CurveSegment::GetFrame (float u, APoint& position, AVector& tangent,
AVector& normal, AVector& binormal) const
{
position = P(u);
AVector velocity = PU(u);
AVector acceleration = PUU(u);
float VDotV = velocity.Dot(velocity);
float VDotA = velocity.Dot(acceleration);
normal = VDotV*acceleration - VDotA*velocity;
normal.Normalize();
tangent = velocity;
tangent.Normalize();
binormal = tangent.Cross(normal);
}
示例5: TestIntersection
//----------------------------------------------------------------------------
bool Bound::TestIntersection (const Bound& bound, float tmax,
const AVector& velocity0, const AVector& velocity1) const
{
if (bound.GetRadius() == 0.0f || GetRadius() == 0.0f)
{
return false;
}
AVector relVelocity = velocity1 - velocity0; // 相对速度
AVector cenDiff = bound.mCenter - mCenter; // 相对位移
float a = relVelocity.SquaredLength();
float c = cenDiff.SquaredLength();
float rSum = bound.mRadius + mRadius;
float rSumSqr = rSum*rSum;
if (a > 0.0f)
{
float b = cenDiff.Dot(relVelocity);
if (b <= 0.0f)
{
if (-tmax*a <= b)
{
return a*c - b*b <= a*rSumSqr;
}
else
{
return tmax*(tmax*a + 2.0f*b) + c <= rSumSqr;
}
}
}
return c <= rSumSqr;
}
示例6: MakePerspectiveProjection
//----------------------------------------------------------------------------
void HMatrix::MakePerspectiveProjection (const APoint& origin,
const AVector& normal, const APoint& eye)
{
// +- -+
// M = | Dot(N,E-P)*I - E*N^T -(Dot(N,E-P)*I - E*N^T)*E |
// | -N^t Dot(N,E) |
// +- -+
//
// where E is the eye point, P is a point on the plane, and N is a
// unit-length plane normal.
float dotND = normal.Dot(eye - origin);
mEntry[ 0] = dotND - eye[0]*normal[0];
mEntry[ 1] = -eye[0]*normal[1];
mEntry[ 2] = -eye[0]*normal[2];
mEntry[ 3] = -(mEntry[0]*eye[0] + mEntry[1]*eye[1] + mEntry[2]*eye[2]);
mEntry[ 4] = -eye[1]*normal[0];
mEntry[ 5] = dotND - eye[1]*normal[1];
mEntry[ 6] = -eye[1]*normal[2];
mEntry[ 7] = -(mEntry[4]*eye[0] + mEntry[5]*eye[1] + mEntry[6]*eye[2]);
mEntry[ 8] = -eye[2]*normal[0];
mEntry[ 9] = -eye[2]*normal[1];
mEntry[10] = dotND- eye[2]*normal[2];
mEntry[11] = -(mEntry[8]*eye[0] + mEntry[9]*eye[1] + mEntry[10]*eye[2]);
mEntry[12] = -normal[0];
mEntry[13] = -normal[1];
mEntry[14] = -normal[2];
mEntry[15] = eye.Dot(normal);
}
示例7: UpdateClods
//----------------------------------------------------------------------------
void ClodMeshes::UpdateClods ()
{
// Adjust the triangle quantities for the clod meshes. The distance along
// the camera direction controls the triangle quantities. A nonlinear
// drop-off is used.
for (int i = 0; i < 2; ++i)
{
AVector diff =
mClod[i]->WorldBound.GetCenter() - mCamera->GetPosition();
float depth = diff.Dot(mCamera->GetDVector());
int targetRecord;
if (depth <= mCamera->GetDMin())
{
targetRecord = 0;
}
else if (depth >= mCamera->GetDMax())
{
targetRecord = mClod[i]->GetNumRecords() - 1;
}
else
{
float dmin = mCamera->GetDMin();
float dmax = mCamera->GetDMax();
float ratio = Mathf::Pow((depth - dmin)/(dmax - dmin), 0.5f);
targetRecord = (int)((mClod[i]->GetNumRecords() - 1)*ratio);
}
mClod[i]->TargetRecord() = targetRecord;
}
}
示例8: GetProjectionMatrix
//----------------------------------------------------------------------------
bool PlanarShadowEffect::GetProjectionMatrix (int i, HMatrix& projection)
{
// Compute the equation for the shadow plane in world coordinates.
APoint vertex[3];
mPlanes[i]->GetWorldTriangle(0, vertex);
HPlane worldPlane(vertex[0], vertex[1], vertex[2]);
// This is a conservative test to see whether a shadow should be cast.
// This can cause incorrect results if the caster is large and intersects
// the plane, but ordinarily we are not trying to cast shadows in such
// situations.
if (mShadowCaster->WorldBound.WhichSide(worldPlane) < 0)
{
// The shadow caster is on the far side of plane, so it cannot cast
// a shadow.
return false;
}
// Compute the projection matrix for the light source.
Light* projector = mProjectors[i];
AVector normal = worldPlane.GetNormal();
if (projector->GetType() == Light::LT_DIRECTIONAL)
{
float NdD = normal.Dot(projector->DVector);
if (NdD >= 0.0f)
{
// The projection must be onto the "positive side" of the plane.
return false;
}
projection.MakeObliqueProjection(vertex[0], normal,
projector->DVector);
}
else if (projector->GetType() == Light::LT_POINT
|| projector->GetType() == Light::LT_SPOT)
{
float NdE = projector->Position.Dot(normal);
if (NdE <= 0.0f)
{
// The projection must be onto the "positive side" of the plane.
return false;
}
projection.MakePerspectiveProjection(vertex[0], normal,
projector->Position);
}
else
{
assertion(false, "Light type not supported.\n");
return false;
}
return true;
}
示例9: _UpdateDirLightCamera
//----------------------------------------------------------------------------
void AmbientRegionActor::_UpdateDirLightCamera()
{
AVector dir = AVector::AnglesToDirection(Mathf::DEG_TO_RAD*mHorAngle,
Mathf::DEG_TO_RAD*mVerAngle);
dir.Normalize();
Scene *scene = DynamicCast<Scene>(GetTopestParent());
if (scene)
{
EnvirParam *envirParam = scene->GetEnvirParam();
Light *lightDir = envirParam->GetLight_Dir();
Projector *projector = envirParam->GetLight_Dir_Projector();
lightDir->Ambient = Float4(mAmbientColor[0], mAmbientColor[1],
mAmbientColor[2], mIntensity);
lightDir->Intensity = mIntensity;
lightDir->Diffuse = Float4(mDiffuseColor[0], mDiffuseColor[1],
mDiffuseColor[2], 1.0f);
lightDir->Specular = Float4(mSpecularColor[0], mSpecularColor[1],
mSpecularColor[2], mSpecularPow);
float upDot = dir.Dot(-AVector::UNIT_Z);
if (upDot >= 0.99f)
{
}
else
{
AVector upTemp = AVector::UNIT_Z;
AVector right = dir.UnitCross(upTemp);
AVector up = right.UnitCross(dir);
lightDir->DVector = dir;
lightDir->UVector = up;
lightDir->RVector = right;
APoint camPos = mLightCameraLookPosition - dir*mLightCameraLookDistance;
projector->SetFrame(camPos, lightDir->DVector,
lightDir->UVector, lightDir->RVector);
}
if (!projector->IsPerspective())
{
projector->SetFrustum(0.1f, 100.0f,
-mLightCameraExtent, mLightCameraExtent, -mLightCameraExtent,
mLightCameraExtent);
}
else
{
projector->SetFrustum(mLightCameraExtent, 1.0f, 1.0f, 100.0f);
}
}
}
示例10: GetVisibleSet
//----------------------------------------------------------------------------
void Renderable::GetVisibleSet (Culler& culler, bool)
{
AdjustTransparent();
const Camera *camera = culler.GetCamera();
assertion(camera!=0, "camera must not be 0.");
AVector cameraDir = camera->GetDVector();
AVector diff = WorldBound.GetCenter() - camera->GetPosition();
mEyeDistance = cameraDir.Dot(diff);
culler.Insert(this);
}
示例11: Orthonormalize
//----------------------------------------------------------------------------
void AVector::Orthonormalize (AVector& vec0, AVector& vec1, AVector& vec2)
{
// 输入的向量为v0,v1,v2,按照下面的方式进行Gram-Schmidt正交化
//
// u0 = v0/|v0|
// u1 = (v1-(u0*v1)u0)/|v1-(u0*v1)u0|
// u2 = (v2-(u0*v2)u0-(u1*v2)u1)/|v2-(u0*v2)u0-(u1*v2)u1|
//
// |A|代表向量A的长度;A*B代表两个向量“点乘”
// 单位化
vec0.Normalize();
// 计算 u1
float dot0 = vec0.Dot(vec1);
vec1 -= dot0*vec0;
vec1.Normalize();
// 计算 u2
float dot1 = vec1.Dot(vec2);
dot0 = vec0.Dot(vec2);
vec2 -= dot0*vec0 + dot1*vec1;
vec2.Normalize();
}
示例12: _RolateCamera
//----------------------------------------------------------------------------
void EU_CanvasStage::_RolateCamera(float horz, float vert)
{
Scene *scene = PX2_PROJ.GetScene();
horz *= 0.4f;
vert *= 0.25f;
if (VT_PERSPECTIVE == mViewType)
{
AVector rVector;
AVector dVector;
AVector uVector;
mStageCameraNode->LocalTransform.GetRDUVector(rVector, dVector, uVector);
// horz
HMatrix incrH(AVector::UNIT_Z, -horz);
dVector = incrH * dVector;
uVector = incrH * uVector;
rVector = incrH * rVector;
// vert
Matrix3f kIncrV(rVector, -vert);
dVector = kIncrV * dVector;
uVector = kIncrV * uVector;
dVector.Normalize();
float dVectorAdj = dVector.Dot(AVector::UNIT_Z);
float dVectorAdj1 = dVector.Dot(-AVector::UNIT_Z);
if (dVectorAdj > 0.9f || dVectorAdj1 > 0.9f)
return;
AVector::Orthonormalize(dVector, uVector, rVector);
mStageCameraNode->LocalTransform.SetRotate(HMatrix(rVector, dVector,
uVector, AVector::ZERO, true));
}
}
示例13: _GetDirIndex
//----------------------------------------------------------------------------
int FramesMesh::_GetDirIndex(const AVector &dir)
{
AVector animVec = dir;
animVec.Normalize();
AVector up = AVector::UNIT_Y;
float dotVal = up.Dot(animVec);
float rad = Mathf::ACos(dotVal);
float degree = Mathf::RAD_TO_DEG * rad;
bool isRight = (dir.X() > 0.0f);
if (0 <= degree && degree < 22.5f)
{
return 0;
}
else if (22.5f <= degree && degree < 67.5f)
{
if (isRight)
return 1;
else
return 7;
}
else if (67.5 <= degree && degree < 112.5f)
{
if (isRight)
return 2;
else
return 6;
}
else if (112.5f <= degree && degree < 157.5f)
{
if (isRight)
return 3;
else
return 5;
}
else if (157.5f <= degree && degree <= 180.0f)
{
return 4;
}
return 0;
}
示例14: Torsion
//----------------------------------------------------------------------------
float CurveSegment::Torsion (float u) const
{
AVector velocity = PU(u);
AVector acceleration = PUU(u);
AVector cross = velocity.Cross(acceleration);
float denom = cross.SquaredLength();
if (denom >= Mathf::ZERO_TOLERANCE)
{
AVector jerk = PUUU(u);
float numer = cross.Dot(jerk);
return numer/denom;
}
else
{
// Torsion is indeterminate, just return 0.
return 0.0f;
}
}
示例15: MakeObliqueProjection
//----------------------------------------------------------------------------
void HMatrix::MakeObliqueProjection (const APoint& origin,
const AVector& normal, const AVector& direction)
{
// The projection plane is Dot(N,X-P) = 0 where N is a 3-by-1 unit-length
// normal vector and P is a 3-by-1 point on the plane. The projection
// is oblique to the plane, in the direction of the 3-by-1 vector D.
// Necessarily Dot(N,D) is not zero for this projection to make sense.
// Given a 3-by-1 point U, compute the intersection of the line U+t*D
// with the plane to obtain t = -Dot(N,U-P)/Dot(N,D). Then
//
// projection(U) = P + [I - D*N^T/Dot(N,D)]*(U-P)
//
// A 4-by-4 homogeneous transformation representing the projection is
//
// +- -+
// M = | D*N^T - Dot(N,D)*I -Dot(N,P)D |
// | 0^T -Dot(N,D) |
// +- -+
//
// where M applies to [U^T 1]^T by M*[U^T 1]^T. The matrix is chosen so
// that M[3][3] > 0 whenever Dot(N,D) < 0 (projection is onto the
// "positive side" of the plane).
float dotND = normal.Dot(direction);
float dotNO = origin.Dot(normal);
mEntry[ 0] = direction[0]*normal[0] - dotND;
mEntry[ 1] = direction[0]*normal[1];
mEntry[ 2] = direction[0]*normal[2];
mEntry[ 3] = -dotNO*direction[0];
mEntry[ 4] = direction[1]*normal[0];
mEntry[ 5] = direction[1]*normal[1] - dotND;
mEntry[ 6] = direction[1]*normal[2];
mEntry[ 7] = -dotNO*direction[1];
mEntry[ 8] = direction[2]*normal[0];
mEntry[ 9] = direction[2]*normal[1];
mEntry[10] = direction[2]*normal[2] - dotND;
mEntry[11] = -dotNO*direction[2];
mEntry[12] = 0.0f;
mEntry[13] = 0.0f;
mEntry[14] = 0.0f;
mEntry[15] = -dotND;
}