getTangent() public method

public getTangent ( float t ) : Vector3
t float
return Vector3
Ejemplo n.º 1
0
        // This returns getPoints() bend/wrapped around the contour of a path.
        // Read http://www.planetclegg.com/projects/WarpingTextToSplines.html

        List <Vector3> getWrapPoints(List <Vector3> oldPts, Curve path)
        {
            BoundingBox bounds = this.getBoundingBox();

            int     i, il;
            Vector3 p;
            float   oldX, oldY, xNorm;

            for (i = 0, il = oldPts.Count; i < il; i++)
            {
                p = oldPts [i];

                oldX = p.x;
                oldY = p.y;

                xNorm = oldX / bounds.maxX;

                // If using actual distance, for length > path, requires line extrusions
                //xNorm = path.getUtoTmapping(xNorm, oldX); // 3 styles. 1) wrap stretched. 2) wrap stretch by arc length 3) warp by actual distance

                xNorm = path.getUtoTmapping(xNorm, oldX);

                // check for out of bounds?

                Vector3 pathPt = path.getPoint(xNorm);
                Vector3 normal = path.getTangent(xNorm);
                //normal.set( -normal.y, normal.x ).multiplyScalar( oldY );
                normal.x = -normal.y;
                normal.y = normal.x;
                normal  *= oldY;

                p.x = pathPt.x + normal.x;
                p.y = pathPt.y + normal.y;
            }

            return(oldPts);
        }
Ejemplo n.º 2
0
        // This returns getPoints() bend/wrapped around the contour of a path.
        // Read http://www.planetclegg.com/projects/WarpingTextToSplines.html
        List<Vector3> getWrapPoints(List<Vector3> oldPts, Curve path)
        {
            BoundingBox bounds = this.getBoundingBox ();

            int i, il;
            Vector3 p;
            float oldX, oldY, xNorm;

            for (i = 0, il = oldPts.Count; i < il; i ++) {

                p = oldPts [i];

                oldX = p.x;
                oldY = p.y;

                xNorm = oldX / bounds.maxX;

                // If using actual distance, for length > path, requires line extrusions
                //xNorm = path.getUtoTmapping(xNorm, oldX); // 3 styles. 1) wrap stretched. 2) wrap stretch by arc length 3) warp by actual distance

                xNorm = path.getUtoTmapping (xNorm, oldX);

                // check for out of bounds?

                Vector3 pathPt = path.getPoint (xNorm);
                Vector3 normal = path.getTangent (xNorm);
                //normal.set( -normal.y, normal.x ).multiplyScalar( oldY );
                normal.x = -normal.y;
                normal.y = normal.x;
                normal *= oldY;

                p.x = pathPt.x + normal.x;
                p.y = pathPt.y + normal.y;

            }

            return oldPts;
        }