void calcHamiltonianmpi(const Interaction *P,
			const SlaterDet* Q, const SlaterDetAux* X,
			double* h)
{
  double v[P->n];
  double t, tcm = 0.0;

  calcT(Q, X, &t); 
  if (P->cm) 
    calcTCM(Q, X, &tcm);
  calcPotentialmpi(P, Q, X, v);

  *h = t - tcm + v[0];
}
Пример #2
0
// Ray Generation
VEC3F* generateRay(int i, int j, float left, float right, float bottom, float top, int nx, int ny, int eVar) {
	VEC3F dPersp;  		// d vector aka -w
	VEC3F oOrtho; 		// orthographic vector (image plane coords)	
	VEC3F e(0, 0, -1);
	double u, v, w, t;	
	
	// SPHERE
	VEC3F c(0, 0, 1); 	// sphere center
	float R = 0.25f;	// radius sphere		
	
	int mode = 1; // mode=0 (orthographic w/ flat image plane), 
				  // mode=1 (perspective w/ odd pixel "checker board" image plane)
	
	// calculate image plane coordinates for orthographic generation
	u = left + ((right-left)*(i + 0.5) / nx);   // image plane coordinate u
	v = bottom + ((top-bottom)*(j + 0.5) / ny); // image plane coordinate v					 			

	//     if(eVar*0.005 < 0.45) {
	// 	e[0] -= eVar*0.005; // change x coord to move left
	// } else {
	// 	e[0] += eVar*0.005; // change x coord to move right
	// }

//	std::cout << eVar*0.005 << std::endl;
//	e[2] += eVar*0.001; // change z coord eye location (if movie being made)

	 // change mode to set image plane coordinate w	
	// if(mode == 0) {	
	// 	w = 0.0; 
	// } else {
	// 	if(i%2 == 0 && j%2 == 0) {
	// 		w = -0.5;
	// 	} else {
	// 		w = 0.0;						 				
	// 	}		
	// }
	
	oOrtho = VEC3F(u, v, w); // ray origin
	dPersp = oOrtho - e; 	 // calculate dPerspective
		
	// calculate t
	t = calcT(e, dPersp, c, R);
			
	// return ray					
	return new VEC3F(e + t*dPersp);
}
cv::Mat SimulatingImage::projectPlane(int pattern) {
    
    cv::Mat img = cv::Mat::zeros(img_size.height, img_size.width, CV_8UC1);
    
    calcCorners();
    
    for (int y = 0; y < img_size.height; ++y) {
        for (int x = 0; x < img_size.width; ++x) {
            cv::Point3d ray = getRay(cv::Point2d(x,y));
            if (isCross(ray)) {
                cv::Point3d p = calcCrossPoint(ray);
                double s = calcS(p);
                double t = calcT(p);
                if (0 <= s && s <= 1 && 0 <= t && t <= 1) {
                    double step;
                    switch (pattern) {
                        case 0: // check
                            step = interval / pattern_size.width;
                            for (int i = 0; 2*i*step <= 1.0; ++i) {
                                if (step*(2*i) <= s && s <= step*(2*i+1)) {
                                    img.at<uchar>(y,x) = 255;
                                    break;
                                }
                            }
                            step = interval / pattern_size.height;
                            for (int i = 0; 2*i*step <= 1.0; ++i) {
                                if (step*(2*i) <= t && t <= step*(2*i+1)) {
                                    img.at<uchar>(y,x) = abs(img.at<uchar>(y,x)-255);
                                    break;
                                }
                            }
                            break;
                        case 1: // vertical strip
                            step = interval / pattern_size.width;
                            for (int i = 0; 2*i*step <= 1.0; ++i) {
                                if (step*(2*i) <= s && s <= step*(2*i+1)) {
                                    img.at<uchar>(y,x) = 255;
                                    break;
                                }
                            }
                            break;
                        case 2: // inverse of 1
                            step = interval / pattern_size.width;
                            for (int i = 0; (2*i+1)*step <= 1.0; ++i) {
                                if (step*(2*i+1) <= s && s <= step*(2*i+2)) {
                                    img.at<uchar>(y,x) = 255;
                                    break;
                                }
                            }
                            break;
                        case 3: // horizontal strip
                            step = interval / pattern_size.height;
                            for (int i = 0; 2*i*step <= 1.0; ++i) {
                                if (step*(2*i) <= t && t <= step*(2*i+1)) {
                                    img.at<uchar>(y,x) = 255;
                                    break;
                                }
                            }
                            break;
                        case 4: // inverse of 3
                            step = interval / pattern_size.height;
                            for (int i = 0; (2*i+1)*step <= 1.0; ++i) {
                                if (step*(2*i+1) <= t && t <= step*(2*i+2)) {
                                    img.at<uchar>(y,x) = 255;
                                    break;
                                }
                            }
                            break;
                    }
                }
            }
        }
    }
    
    return img;
}