Esempio n. 1
0
void L0ByEdge::updateInfo()
{
    int i, j;
    for(i = 0;i < arinfocnt;i++)
    {
        for(j = 0;j < 4;j++)
        {
            if(j % 2 ==	0)
                info[i][j].w = 1 * arpha;
            else
                info[i][j].w = -1 * arpha;
        }
    }

    for(i = arinfocnt;i < infocnt;i++)
    {
        int p1 = info[i][0].data;
        int p2 = info[i][1].data;
        int p3 = info[i][2].data;
        int p4 = info[i][3].data;

        double p1p2 = getPointDistance(p1, p2);
        double p2p3 = getPointDistance(p2, p3);
        double p1p3 = getPointDistance(p1, p3);
        double p1p4 = getPointDistance(p1, p4);
        double p3p4 = getPointDistance(p3, p4);

        double angle_312 = getPointAngle(p2p3, p1p2, p1p3);
        double angle_231 = getPointAngle(p1p2, p2p3, p1p3);
        double angle_413 = getPointAngle(p3p4, p1p3, p1p4);
        double angle_134 = getPointAngle(p1p4, p1p3, p3p4);

        double area123 = 0.5 * p2p3 * p1p3 * sin(angle_231);
        double area134 = 0.5 * p3p4 * p1p3 * sin(angle_134);

        double fenmu;
        fenmu = (p1p3) * (p1p3) * (area123 + area134);
        if(fenmu < 1e-14)
            fenmu = 1e-14;
        info[i][0].w = (area123 * getPointFactor(p4,p3,p3,p1) + area134 * getPointFactor(p1,p3,p3,p2)) / (fenmu);

        fenmu = area123 + area134;
        if(fenmu < 1e-14)
            fenmu = 1e-14;
        info[i][1].w = area134 / (fenmu);

        fenmu = (p1p3) * (p1p3) * (area123 + area134);
        if(fenmu < 1e-14)
            fenmu = 1e-14;
        info[i][2].w = (area123 * getPointFactor(p3,p1,p1,p4) + area134 * getPointFactor(p2,p1,p1,p3)) / (fenmu);

        fenmu = area123 + area134;
        if(fenmu < 1e-14)
            fenmu = 1e-14;
        info[i][3].w = area123 / (fenmu);
    }
}
Esempio n. 2
0
void L0ByEdge::autoGetParameter()
{
    double sumLength = 0,sumAngle = 0;
    double averageLength = 0.0,averageAngle = 0.0;
    Edge *edgetail = edge;

    while(edgetail){
        sumLength += getPointDistance(edgetail->p[0],edgetail->p[2]);
        sumAngle += getAngleByFaceIndex(edgetail->f[0],edgetail->f[1]);
        edgetail = edgetail->next;
    }
    if(edgeNum <= 0){
        printf("L0ByEdge::autoGetParameter\n");
        return ;
    }
    averageLength = sumLength / edgeNum;
    averageAngle = sumAngle / edgeNum;
    arpha = 0.1 * averageAngle;
    lambda = 0.02 * averageLength * averageLength * averageAngle;
    beta = 0.001;
    maxtimes = 40;
}
Esempio n. 3
0
	virtual bool raycast(const double *from,			// The starting point of the raycast
		const double *to,				// The ending point of the raycast
		const double *closestToPoint,	// The point to match the nearest hit location (can just be the 'from' location of no specific point)
		double *hitLocation,			// The point where the ray hit nearest to the 'closestToPoint' location
		double *hitDistance) final		// The distance the ray traveled to the hit location
	{
		bool ret = false;

		double dir[3];

		dir[0] = to[0] - from[0];
		dir[1] = to[1] - from[1];
		dir[2] = to[2] - from[2];

		double distance = sqrt( dir[0]*dir[0] + dir[1]*dir[1]+dir[2]*dir[2] );
		if ( distance < 0.0000000001f ) return false;
		double recipDistance = 1.0f / distance;
		dir[0]*=recipDistance;
		dir[1]*=recipDistance;
		dir[2]*=recipDistance;
		const uint32_t *indices = mIndices;
		const double *vertices = mVertices;
		double nearestDistance = distance;

		for (uint32_t tri=0; tri<mTcount; tri++)
		{
			uint32_t i1 = indices[tri*3+0];
			uint32_t i2 = indices[tri*3+1];
			uint32_t i3 = indices[tri*3+2];

			const double *p1 = &vertices[i1*3];
			const double *p2 = &vertices[i2*3];
			const double *p3 = &vertices[i3*3];

			double t;
			if ( rayIntersectsTriangle(from,dir,p1,p2,p3,t))
			{
				double hitPos[3];

				hitPos[0] = from[0] + dir[0] * t;
				hitPos[1] = from[1] + dir[1] * t;
				hitPos[2] = from[2] + dir[2] * t;

				double pointDistance = getPointDistance(hitPos, closestToPoint);

				if (pointDistance < nearestDistance )
				{
					nearestDistance = pointDistance;
					if ( hitLocation )
					{
						hitLocation[0] = hitPos[0];
						hitLocation[1] = hitPos[1];
						hitLocation[2] = hitPos[2];
					}
					if ( hitDistance )
					{
						*hitDistance = pointDistance;
					}
					ret = true;
				}
			}
		}
		return ret;
	}
Esempio n. 4
0
void PivotTable::recalcPivotLength ( const TrussPivot& pivot )
{
    double length = getPointDistance( pivot.getFirstNode().getPoint(), 
                                      pivot.getLastNode().getPoint() );
    setPivotLength( pivot.getNumber() - 1, length );
}