Example #1
0
void features3D::setPoint(float x, float y, float z)
{
	m_x = x;
	m_y = y;
	m_z = z;
	cartesianToPolar();
}
Example #2
0
features3D::features3D(int id, float x, float y, float z, bool exists)
{
	m_id = id;
	m_x = x;
	m_y = y;
	m_z = z;
	m_exists = exists;
	cartesianToPolar();
}
Example #3
0
int main(int argc, const char * argv[])
{
    double x = 3.0;
    double y = 4.0;
    double radius;
    double angle;
    
    cartesianToPolar(x, y, &radius, &angle);
    printf("(%.2f, %.2f) becomes (%.2f radians, %.2f)\n", x, y, radius, angle);
    
    return 0;
}
Example #4
0
int main(int argc, const char * argv[])
{
    double pi = 3.14;
    double integerPart;
    double fractionPart;
    
    fractionPart = modf(pi, &integerPart);
    
    printf("integerPart = %.0f, fractionPart = %.2f\n", integerPart, fractionPart);
    
    double x = 3;
    double y = 4;
    double radius = 0;
    double angle = 0;
    cartesianToPolar(x, y, &radius, &angle);
    printf("(%.2f, %.2f) becomes (%.2fradians, %.2f)\n", x, y, angle, radius);
}
Example #5
0
int main(int argc, const char * argv[]) {
    double pi = 3.14;
    double integerPart;
    double fractionPart;
    
    //Адрес integerPart передается в аргументе
    fractionPart = modf(pi, &integerPart);
    //Определение значения, хранященося в integerPart
    printf("integerPart = %.0f, fractionPart = %.2f\n", integerPart, fractionPart);
    
    double x = 3.0;
    double y = 4.0;
    double radius;
    double angle;
    
    cartesianToPolar(x, y, &radius, &angle);
    printf("(%.2f, %.2f) becomes (%.2f radians. %.2f)\n", x, y, radius, angle);
    
    return 0;
}
Example #6
0
int main(int argc, const char * argv[])
{
    double pi = 3.14;
    double integerPart;
    double fractionPart;
    
    // 将integerPart的地址作为实参传入
    fractionPart = modf(pi, &integerPart);
    
    // 获取integer地址上的值
    printf("integerPart = %.0f, fractionPart = %.2f.\n", integerPart, fractionPart);
    
    double x = 3.0;
    double y = 4.0;
    double radius;
    double angle;
    cartesianToPolar(x, y, &radius, &angle);
    printf("(%.2f, %.2f) becomes (%.2f radians, %.2f)\n", x, y, radius, angle);
    
    return 0;
}
Example #7
0
int main(int argc, const char * argv[])
{
    double pi = 3.14;
    double integerPart;
    double fractionPart;
    
    // Pass the address of integerPart as an argument
    fractionPart = modf(pi, &integerPart);
    
    // Find the value stored in integerPart
    printf("integerPart = %.0f, fractionPart = %.2f\n", integerPart, fractionPart);
    
    double x = 3.0;
    double y = 4.0;
    double radius;
    double angle;
    
    cartesianToPolar(x, y, &radius, &angle);
    printf("(%.2f, %.2f) becomes (%.2f radians, %.2f)\n", x, y, radius, angle);
    
    return 0;
}
Example #8
0
Mat FindContour::curveSmooth(Mat &contourImg,
                int WIN, // half window size for laplacian smoothing
                vector<Point> &border,
                vector<Point> &smooth,
                /*Point cntoid*/vector<Point> &convHull )
{
//    if(contourImg.type() != CV_8UC1){
//        cvtColor( contourImg, contourImg, CV_BGR2GRAY );
//    }
    double width = contourImg.cols;
    double height = contourImg.rows;

    Moments mu = moments(convHull);
//    Moments mu = moments(border);
    Point cntoid = Point2f(mu.m10/mu.m00/* + rect.x*/, mu.m01/mu.m00/* +rect.y*/);

    double d_min = max(width, height)*max(width, height);
    vector<polarPoint> border_polar;
    for (unsigned int n = 0; n < border.size(); n++)
    {
        //find the polar coordinates of the border;
        border_polar.push_back(cartesianToPolar(cntoid, border[n]));

        //find the nearest point to the center on the border
        double d = dist(cntoid, border[n]);
        if(d < d_min){
            d_min = d;
        }
    }
    d_min = sqrt(d_min);

    // sort border_polar by theta
    sort(border_polar.begin(), border_polar.end(), sortByTheta);

    // Laplacian smoothing
    unsigned int border_size = border_polar.size();
    for(unsigned int n = 0; n < border_size; n++){
        //cout << border_polar[n].r << " " << border_polar[n].theta << "  ";

        double avg = 0;
        for(int w = -WIN; w < WIN; w++){
            unsigned int pos = std::fabs((w+n+border_size)%border_size);
            //cout << " pos " << pos << "  ";
            avg += border_polar[pos].r;
        }
        avg = avg/WIN/2;
        polarPoint polar;
        polar.r = avg;
        polar.theta = border_polar[n].theta;
        //cout << polar.r << " " << polar.theta << " ";
        Point p = polarToCartesian(cntoid, polar);
        //circle(color, p, 1, Scalar(255, 255, 0));
        smooth.push_back(p);
        //cout << p.x << " " << p.y << "\n";
    }

    Mat smoothCircle = Mat::zeros(height, width, CV_8UC1);
    fillConvexPoly(smoothCircle, smooth, Scalar(255));
//    fillPoly(smoothCircle, smooth, Scalar(255));
    //imshow("smoothCircle", smoothCircle);

    return smoothCircle;
}
Example #9
0
void convertDatum(double* x, double* y, double* z, struct datum* fromDatum, struct datum* todatum) {
    polarToCartesian(x,y,z, fromDatum);
    helmertTransform(x,y,z, fromDatum, todatum);
    cartesianToPolar(x,y,z, todatum);
}