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


C++ Plane3::DistanceTo方法代码示例

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


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

示例1:

bool ConvexPolyhedron3<Real>::ComputeSilhouette (V3Array& rkTerminator,
    const Vector3<Real>& rkEye, const Plane3<Real>& rkPlane,
    const Vector3<Real>& rkU, const Vector3<Real>& rkV,
    V2Array& rkSilhouette)
{
    Real fEDist = rkPlane.DistanceTo(rkEye);  // assert:  fEDist > 0

    // closest planar point to E is K = E-dist*N
    Vector3<Real> kClosest = rkEye - fEDist*rkPlane.GetNormal();

    // project polyhedron points onto plane
    for (int i = 0; i < (int)rkTerminator.size(); i++)
    {
        Vector3<Real>& rkPoint = rkTerminator[i];

        Real fVDist = rkPlane.DistanceTo(rkPoint);
        if ( fVDist >= fEDist )
        {
            // cannot project vertex onto plane
            return false;
        }

        // compute projected point Q
        Real fRatio = fEDist/(fEDist-fVDist);
        Vector3<Real> kProjected = rkEye + fRatio*(rkPoint - rkEye);

        // compute (x,y) so that Q = K+x*U+y*V+z*N
        Vector3<Real> kDiff = kProjected - kClosest;
        rkSilhouette.push_back(Vector2<Real>(rkU.Dot(kDiff),rkV.Dot(kDiff)));
    }

    return true;
}
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:33,代码来源:WmlConvexPolyhedron3.cpp

示例2: Culled

bool Wml::Culled (const Plane3<Real>& rkPlane, const Box3<Real>& rkBox)
{
    Real fTmp[3] =
    {
        rkBox.Extent(0)*(rkPlane.GetNormal().Dot(rkBox.Axis(0))),
        rkBox.Extent(1)*(rkPlane.GetNormal().Dot(rkBox.Axis(1))),
        rkBox.Extent(2)*(rkPlane.GetNormal().Dot(rkBox.Axis(2)))
    };

    Real fRadius = Math<Real>::FAbs(fTmp[0]) + Math<Real>::FAbs(fTmp[1]) +
        Math<Real>::FAbs(fTmp[2]);

    Real fPseudoDistance = rkPlane.DistanceTo(rkBox.Center());
    return fPseudoDistance <= -fRadius;
}
开发者ID:Steven0818,项目名称:Deform,代码行数:15,代码来源:WmlIntrPln3Box3.cpp

示例3: WhichSide

int BVaabb::WhichSide(const Plane3& plane) const
{
	if (mAlwaysPass)
		return 1;
	Real fDistance = plane.DistanceTo(mCenter);
	if (fDistance <= -mRadius)
	{
		return -1;
	}

	if (fDistance >= mRadius)
	{
		return +1;
	}

	return 0;
}
开发者ID:fastbird,项目名称:fastbirdEngine_NewAPI,代码行数:17,代码来源:BVaabb.cpp

示例4: PerspectiveProjectEllipsoid

void PerspectiveProjectEllipsoid (const Ellipsoid3<Real>& ellipsoid,
    const Vector3<Real>& eye, const Plane3<Real>& plane,
    const Vector3<Real>& U, const Vector3<Real>& V, Vector3<Real>& P,
    Ellipse2<Real>& ellipse)
{
    // Get coefficients for ellipsoid as X^T*A*X + B^T*X + C = 0.
    Matrix3<Real> A;
    Vector3<Real> B;
    Real C;
    ellipsoid.ToCoefficients(A, B, C);

    // Compute matrix M (see PerspectiveProjectionEllipsoid.pdf).
    Vector3<Real> AE = A*eye;
    Real EAE = eye.Dot(AE);
    Real BE = B.Dot(eye);
    Real QuadE = ((Real)4)*(EAE + BE + C);
    Vector3<Real> Bp2AE = B + ((Real)2)*AE;
    Matrix3<Real> mat = Matrix3<Real>(Bp2AE, Bp2AE) - QuadE*A;

    // Compute coefficients for projected ellipse.
    Vector3<Real> MU = mat*U;
    Vector3<Real> MV = mat*V;
    Vector3<Real> MN = mat*plane.Normal;
    Real DmNdE = -plane.DistanceTo(eye);
    P = eye + DmNdE*plane.Normal;

    Matrix2<Real> AOut;
    Vector2<Real> BOut;
    Real COut;
    AOut[0][0] = U.Dot(MU);
    AOut[0][1] = U.Dot(MV);
    AOut[1][1] = V.Dot(MV);
    AOut[1][0] = AOut[0][1];
    BOut[0] = ((Real)2)*DmNdE*(U.Dot(MN));
    BOut[1] = ((Real)2)*DmNdE*(V.Dot(MN));
    COut = DmNdE*DmNdE*(plane.Normal.Dot(MN));
    ellipse.FromCoefficients(AOut, BOut, COut);
}
开发者ID:fishxz,项目名称:omni-bot,代码行数:38,代码来源:Wm5PerspProjEllipsoid.cpp

示例5: if

int ConvexClipper<Real>::Clip (const Plane3<Real>& plane)
{
    // Sompute signed distances from vertices to plane.
    int numPositive = 0, numNegative = 0;
    const int numVertices = (int)mVertices.size();
    for (int v = 0; v < numVertices; ++v)
    {
        Vertex& vertex = mVertices[v];
        if (vertex.Visible)
        {
            vertex.Distance = plane.DistanceTo(vertex.Point);
            if (vertex.Distance >= mEpsilon)
            {
                ++numPositive;
            }
            else if (vertex.Distance <= -mEpsilon)
            {
                ++numNegative;
                vertex.Visible = false;
            }
            else
            {
                // The point is on the plane (within floating point
                // tolerance).
                vertex.Distance = (Real)0;
            }
        }
    }

    if (numPositive == 0)
    {
        // Mesh is in negative half-space, fully clipped.
        return -1;
    }

    if (numNegative == 0)
    {
        // Mesh is in positive half-space, fully visible.
        return +1;
    }

    // Clip the visible edges.
    const int numEdges = (int)mEdges.size();
    for (int e = 0; e < numEdges; ++e)
    {
        Edge& edge = mEdges[e];
        if (edge.Visible)
        {
            int v0 = edge.Vertex[0];
            int v1 = edge.Vertex[1];
            int f0 = edge.Face[0];
            int f1 = edge.Face[1];
            Face& face0 = mFaces[f0];
            Face& face1 = mFaces[f1];
            Real d0 = mVertices[v0].Distance;
            Real d1 = mVertices[v1].Distance;

            if (d0 <= (Real)0 && d1 <= (Real)0)
            {
                // The edge is culled.  If the edge is exactly on the clip
                // plane, it is possible that a visible triangle shares it.
                // The edge will be re-added during the face loop.
                face0.Edges.erase(e);
                if (face0.Edges.empty())
                {
                    face0.Visible = false;
                }

                face1.Edges.erase(e);
                if (face1.Edges.empty())
                {
                    face1.Visible = false;
                }

                edge.Visible = false;
                continue;
            }

            if (d0 >= (Real)0 && d1 >= (Real)0)
            {
                // Face retains the edge.
                continue;
            }

            // The edge is split by the plane.  Compute the point of
            // intersection.  If the old edge is <V0,V1> and I is the
            // intersection point, the new edge is <V0,I> when d0 > 0 or
            // <I,V1> when d1 > 0.
            int vNew = (int)mVertices.size();
            mVertices.push_back(Vertex());
            Vertex& vertexNew = mVertices[vNew];

            Vector3<Real>& point0 = mVertices[v0].Point;
            Vector3<Real>& point1 = mVertices[v1].Point;
            vertexNew.Point = point0 + (d0/(d0 - d1))*(point1 - point0);

            if (d0 > (Real)0)
            {
                edge.Vertex[1] = vNew;
            }
//.........这里部分代码省略.........
开发者ID:rasslingcats,项目名称:calico,代码行数:101,代码来源:ConvexClipper.cpp

示例6: if

void IntrTetrahedron3Tetrahedron3<Real>::SplitAndDecompose (
    Tetrahedron3<Real> tetra, const Plane3<Real>& plane,
    std::vector<Tetrahedron3<Real> >& inside)
{
    // Determine on which side of the plane the points of the tetrahedron lie.
    Real C[4];
    int i, pos[4], neg[4], zer[4];
    int positive = 0, negative = 0, zero = 0;

    for (i = 0; i < 4; ++i)
    {
        C[i] = plane.DistanceTo(tetra.V[i]);
        if (C[i] > (Real)0)
        {
            pos[positive++] = i;
        }
        else if (C[i] < (Real)0)
        {
            neg[negative++] = i;
        }
        else
        {
            zer[zero++] = i;
        }
    }

    // For a split to occur, one of the c_i must be positive and one must
    // be negative.

    if (negative == 0)
    {
        // Tetrahedron is completely on the positive side of plane, full clip.
        return;
    }

    if (positive == 0)
    {
        // Tetrahedron is completely on the negative side of plane.
        inside.push_back(tetra);
        return;
    }

    // Tetrahedron is split by plane.  Determine how it is split and how to
    // decompose the negative-side portion into tetrahedra (6 cases).
    Real w0, w1, invCDiff;
    Vector3<Real> intp[4];

    if (positive == 3)
    {
        // +++-
        for (i = 0; i < positive; ++i)
        {
            invCDiff = ((Real)1)/(C[pos[i]] - C[neg[0]]);
            w0 = -C[neg[0]]*invCDiff;
            w1 = +C[pos[i]]*invCDiff;
            tetra.V[pos[i]] = w0*tetra.V[pos[i]] +
                w1*tetra.V[neg[0]];
        }
        inside.push_back(tetra);
    }
    else if (positive == 2)
    {
        if (negative == 2)
        {
            // ++--
            for (i = 0; i < positive; ++i)
            {
                invCDiff = ((Real)1)/(C[pos[i]] - C[neg[0]]);
                w0 = -C[neg[0]]*invCDiff;
                w1 = +C[pos[i]]*invCDiff;
                intp[i] = w0*tetra.V[pos[i]] + w1*tetra.V[neg[0]];
            }
            for (i = 0; i < negative; ++i)
            {
                invCDiff = ((Real)1)/(C[pos[i]] - C[neg[1]]);
                w0 = -C[neg[1]]*invCDiff;
                w1 = +C[pos[i]]*invCDiff;
                intp[i+2] = w0*tetra.V[pos[i]] +
                    w1*tetra.V[neg[1]];
            }

            tetra.V[pos[0]] = intp[2];
            tetra.V[pos[1]] = intp[1];
            inside.push_back(tetra);

            inside.push_back(Tetrahedron3<Real>(tetra.V[neg[1]],
                intp[3], intp[2], intp[1]));

            inside.push_back(Tetrahedron3<Real>(tetra.V[neg[0]],
                intp[0], intp[1], intp[2]));
        }
        else
        {
            // ++-0
            for (i = 0; i < positive; ++i)
            {
                invCDiff = ((Real)1)/(C[pos[i]] - C[neg[0]]);
                w0 = -C[neg[0]]*invCDiff;
                w1 = +C[pos[i]]*invCDiff;
                tetra.V[pos[i]] = w0*tetra.V[pos[i]] +
//.........这里部分代码省略.........
开发者ID:Kiichi77,项目名称:WildMagic,代码行数:101,代码来源:Wm5IntrTetrahedron3Tetrahedron3.cpp


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