Example #1
0
void DoubleImage::mapPoints(const Triangle* t, TriFit fit, gdImagePtr to, Channel channel) {
	if (gdImageSX(image) != gdImageSX(to) || gdImageSY(image) != gdImageSY(to)) {
		throw logic_error("dimensions don't match!!!");
	}

	switch(sType) {
	case T_BOTHSAMPLE:
	case T_SUBSAMPLE: {
		const vector<Point2D>& points = getPointsInside(t);

//		const AffineTransform trans = AffineTransform(*fit.best, *t, fit.pMap).getInverse();
		const AffineTransform trans = AffineTransform(*t, *fit.best, fit.pMap);

		for (vector<Point2D>::const_iterator it = points.begin(); it != points.end(); it++) {
			mapPoint(to, fit, trans.transform(*it), *it, channel);
		}
		if (sType != T_BOTHSAMPLE) {
			break;
		}
	}
	case T_SUPERSAMPLE: {
		const vector<Point2D>& points = getPointsInside(fit.best);

		const AffineTransform trans = AffineTransform(*fit.best, *t, fit.pMap);

		for (vector<Point2D>::const_iterator it = points.begin(); it != points.end(); it++) {
			mapPoint(to, fit, *it, trans.transform(*it), channel);
		}

		break;
	}
	}
}
Example #2
0
// result[P000] is the DOMAIN e.g. the larger triangle
map<TriFit::PointMap, vector<double> > DoubleImage::getAllConfigurations(const Triangle* smaller, const Triangle* larger, Channel channel) {
	map<TriFit::PointMap, vector<double> > result;

	const vector<Point2D>& smallerPoints = getPointsInside(smaller);

	for (char i = 0; i < TriFit::NUM_MAPS; i++) {
		const TriFit::PointMap m = TriFit::pointMapFromInt(i);

		result[m] = vector<double>(0);
		vector<double>& v = result[m];

//		const AffineTransform small2large = AffineTransform(*larger, *smaller, m).getInverse();
		const AffineTransform small2large = AffineTransform(*smaller, *larger, m);

		v.reserve(smallerPoints.size());

		for (vector<Point2D>::const_iterator it = smallerPoints.begin(); it != smallerPoints.end(); it++) {
			v.push_back(valueAt(small2large.transform(*it), channel));
		}
	}

	result[TriFit::P000] = vector<double>(0);
	vector<double>& v = result[TriFit::P000];

	v.reserve(smallerPoints.size());

	for (vector<Point2D>::const_iterator it = smallerPoints.begin(); it != smallerPoints.end(); it++) {
		v.push_back(valueAt(*it, channel));
	}

	return result;
}
    Vector2 convertPosUp(Actor* src, Actor* dest, const Vector2& pos, bool direction)
    {
        Vector2 locPos = pos;
        AffineTransform t;
        t.identity();
        //t = src->getTransform();
        while (src != dest && src)
        {
            t = src->getTransform() * t;
            src = src->getParent();
        }


        if (direction)
        {
            t.x = 0;
            t.y = 0;
        }

        locPos = t.transform(locPos);
        return locPos;
    }