当前位置: 首页>>代码示例>>C++>>正文


C++ float3::LengthSq方法代码示例

本文整理汇总了C++中float3::LengthSq方法的典型用法代码示例。如果您正苦于以下问题:C++ float3::LengthSq方法的具体用法?C++ float3::LengthSq怎么用?C++ float3::LengthSq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在float3的用法示例。


在下文中一共展示了float3::LengthSq方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

float float3::AngleBetween(const float3 &other) const
{
	float cosa = Dot(other) / Sqrt(LengthSq() * other.LengthSq());
	if (cosa >= 1.f)
		return 0.f;
	else if (cosa <= -1.f)
		return pi;
	else
		return acos(cosa);
}
开发者ID:chengzg,项目名称:MathGeoLib,代码行数:10,代码来源:float3.cpp

示例2: IntersectionSpherePoint

//--------------------------------------------------------------------------------------------------------
//	checks point-intersection with sphere (point is relative to owner)
//--------------------------------------------------------------------------------------------------------
Bool GCollisionObj::IntersectionSpherePoint(float3 Point)
{
	//	translate so point is local to sphere
	Point += m_Offset;

	//	get dist to point
	float DistSq = Point.LengthSq();

	if ( DistSq > (m_SphereRadius*m_SphereRadius) )
		return FALSE;

	return TRUE;
}
开发者ID:SoylentGraham,项目名称:GutGut,代码行数:16,代码来源:GCollisionObject.cpp

示例3: ApplyTorqueImpulse

void RigidBody::ApplyTorqueImpulse(const float3& torqueImpulse)
{
    // Cannot modify server-authoritative physics object
    if (!HasAuthority())
        return;
    
    // If impulse is very small, do not wake up the body and apply
    if (torqueImpulse.LengthSq() < cTorqueThresholdSq)
        return;
        
    if (!impl->body)
        CreateBody();
    if (impl->body)
    {
        Activate();
        impl->body->applyTorqueImpulse(torqueImpulse);
    }
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:18,代码来源:RigidBody.cpp

示例4: ApplyImpulse

void RigidBody::ApplyImpulse(const float3& impulse, const float3& position)
{
    // Cannot modify server-authoritative physics object
    if (!HasAuthority())
        return;
    
    // If impulse is very small, do not wake up the body and apply
    if (impulse.LengthSq() < cImpulseThresholdSq)
        return;
    
    if (!impl->body)
        CreateBody();
    if (impl->body)
    {
        Activate();
        if (position.Equals(float3::zero))
            impl->body->applyCentralImpulse(impulse);
        else
            impl->body->applyImpulse(impulse, position);
    }
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:21,代码来源:RigidBody.cpp

示例5:

float3 float3::ProjectTo(const float3 &direction) const
{
	assume(!direction.IsZero());
	return direction * this->Dot(direction) / direction.LengthSq();
}
开发者ID:chengzg,项目名称:MathGeoLib,代码行数:5,代码来源:float3.cpp

示例6: assume

float4 float4::ProjectTo3(const float3 &target) const
{
    assume(!target.IsZero());
    assume(this->IsWZeroOrOne());
    return float4(target * Dot(xyz(), target) / target.LengthSq(), w);
}
开发者ID:zhimaijoy,项目名称:tundra,代码行数:6,代码来源:float4.cpp

示例7: IntersectLineAABB_CPP

bool AABB::IntersectLineAABB_CPP(const float3 &linePos, const float3 &lineDir, float &tNear, float &tFar) const
{
	assume2(lineDir.IsNormalized(), lineDir, lineDir.LengthSq());
	assume2(tNear <= tFar && "AABB::IntersectLineAABB: User gave a degenerate line as input for the intersection test!", tNear, tFar);
	// The user should have inputted values for tNear and tFar to specify the desired subrange [tNear, tFar] of the line
	// for this intersection test.
	// For a Line-AABB test, pass in
	//    tNear = -FLOAT_INF;
	//    tFar = FLOAT_INF;
	// For a Ray-AABB test, pass in
	//    tNear = 0.f;
	//    tFar = FLOAT_INF;
	// For a LineSegment-AABB test, pass in
	//    tNear = 0.f;
	//    tFar = LineSegment.Length();

	// Test each cardinal plane (X, Y and Z) in turn.
	if (!EqualAbs(lineDir.x, 0.f))
	{
		float recipDir = RecipFast(lineDir.x);
		float t1 = (minPoint.x - linePos.x) * recipDir;
		float t2 = (maxPoint.x - linePos.x) * recipDir;

		// tNear tracks distance to intersect (enter) the AABB.
		// tFar tracks the distance to exit the AABB.
		if (t1 < t2)
			tNear = Max(t1, tNear), tFar = Min(t2, tFar);
		else // Swap t1 and t2.
			tNear = Max(t2, tNear), tFar = Min(t1, tFar);

		if (tNear > tFar)
			return false; // Box is missed since we "exit" before entering it.
	}
	else if (linePos.x < minPoint.x || linePos.x > maxPoint.x)
		return false; // The ray can't possibly enter the box, abort.

	if (!EqualAbs(lineDir.y, 0.f))
	{
		float recipDir = RecipFast(lineDir.y);
		float t1 = (minPoint.y - linePos.y) * recipDir;
		float t2 = (maxPoint.y - linePos.y) * recipDir;

		if (t1 < t2)
			tNear = Max(t1, tNear), tFar = Min(t2, tFar);
		else // Swap t1 and t2.
			tNear = Max(t2, tNear), tFar = Min(t1, tFar);

		if (tNear > tFar)
			return false; // Box is missed since we "exit" before entering it.
	}
	else if (linePos.y < minPoint.y || linePos.y > maxPoint.y)
		return false; // The ray can't possibly enter the box, abort.

	if (!EqualAbs(lineDir.z, 0.f)) // ray is parallel to plane in question
	{
		float recipDir = RecipFast(lineDir.z);
		float t1 = (minPoint.z - linePos.z) * recipDir;
		float t2 = (maxPoint.z - linePos.z) * recipDir;

		if (t1 < t2)
			tNear = Max(t1, tNear), tFar = Min(t2, tFar);
		else // Swap t1 and t2.
			tNear = Max(t2, tNear), tFar = Min(t1, tFar);
	}
	else if (linePos.z < minPoint.z || linePos.z > maxPoint.z)
		return false; // The ray can't possibly enter the box, abort.

	return tNear <= tFar;
}
开发者ID:chengzg,项目名称:MathGeoLib,代码行数:69,代码来源:AABB.cpp

示例8: Dot

bool float3::IsPerpendicular(const float3 &other, float epsilonSq) const
{
	float dot = Dot(other);
	return dot*dot <= epsilonSq * LengthSq() * other.LengthSq();
}
开发者ID:truongascii,项目名称:MathGeoLib,代码行数:5,代码来源:float3.cpp


注:本文中的float3::LengthSq方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。