Beispiel #1
0
void set_high_res_screen_image_viewangle_2 ( void )
{

	full_screen_width_view_angle = rad ( 90 );

	full_screen_height_view_angle = rad ( 73.74 );
}
Beispiel #2
0
void set_high_res_screen_image_viewangle_3 ( void )
{

	full_screen_width_view_angle = rad ( 120 );

	full_screen_height_view_angle = rad ( 104.82 );
}
Beispiel #3
0
Matrix rot(Matrix a, double theta, int axis)
{
	if(axis!=1 && axis!=2 && axis!=3){
		printf("Error, axis must equal 1, 2, or 3.");
		exit(EXIT_FAILURE);
	}
    /*left or right coordianate system??*/
	double s, c;
	Matrix r, rot;
	r = new_matrix(4, 4);
	rot = new_matrix(4, 4);
	
	s = sin(rad(theta));
	c = cos(rad(theta));
	double elem1[16] = {1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1};
	double elem2[16] = {c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1};
	double elem3[16] = {c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
	
	switch(axis){
	    case 1:
		    rot.t = elem1;
			break;
		case 2:
		    rot.t = elem2;
			break;
		case 3:
		    rot.t = elem3;
			break;
	}
	r = matrix_mult(rot, a);
	
	return r;
}
Beispiel #4
0
void set_high_res_screen_image_viewangle_1 ( void )
{

	full_screen_width_view_angle = rad ( 59.99 );

	full_screen_height_view_angle = rad ( 46.82 );
}
Beispiel #5
0
void set_high_res_screen_image_viewangle_4 ( void )
{

	full_screen_width_view_angle = rad ( 20 );

	full_screen_height_view_angle = rad ( 15.6 );
}
Beispiel #6
0
/* Create a valid vector for the dataset. */
static vector * citi_create_vector (struct citi_package_t * p, int i,
				    char * n, char * type) {
  vector * vec;
  vec = citi_get_vector (p, i); // fetch vector
  vec = new vector (*vec);      // copy vector
  vec->reverse ();              // reverse vector

  // convert data if necessary
  if (!strcmp (type, "MAGANGLE")) {
    for (int i = 0; i < vec->getSize (); i++) {
      nr_complex_t val = vec->get (i);
      val = polar (real (val), rad (imag (val)));
      vec->set (val, i);
    }
  }
  else if (!strcmp (type, "DBANGLE")) {
    for (int i = 0; i < vec->getSize (); i++) {
      nr_complex_t val = vec->get (i);
      val = polar (pow (10.0, real (val) / 20.0), rad (imag (val)));
      vec->set (val, i);
    }
  }

  // return named vector
  vec->setName (n);
  return vec;
}
Beispiel #7
0
int main(int argc, char** argv) {
	long nrh, nrl, nch, ncl;
	byte** I;
	byte** binary;
	byte** droits;

	int theta, roMax, ro;
	int** tableRT;

	I = LoadPGM_bmatrix("route0.pgm", &nrl, &nrh, &ncl, &nch);

	binary = bmatrix(nrl, nrh, ncl, nch);
	roMax = sqrt(nrh * nrh + nch * nch);
	tableRT = imatrix(0, 179, 0, roMax);
	droits = bmatrix(0, 179, 0, roMax);

	int i, j;
	for (i = nrl; i < nrh; i++) {
		for (j = ncl; j < nch; j++) {
			if (I[i][j] >= 180)
				binary[i][j] = 255;
			else
				binary[i][j] = 0;
		}
	}

	for (theta = 0; theta < 180; theta++) {
		for (ro = 0; ro < roMax; ro++) {
			tableRT[theta][ro] = 0;
		}
	}

	for (theta = 0; theta < 180; theta++) {
		for (i = nrl; i < nrh; i++) {
			for (j = ncl; j < nch; j++) {
				if (I[i][j] >= 180) {
					ro = i * cos(rad(theta)) + j * sin(rad(theta));
					tableRT[theta][abs(ro)]++;
				}

			}
		}
	}
	int max = 0;
	for (theta = 0; theta < 180; theta++) {
		for (ro = 0; ro < roMax; ro++) {
			if (tableRT[theta][ro] > max) {
				max = tableRT[theta][ro];
			}
		}
	}

	SavePGM_bmatrix(binary, nrl, nrh, ncl, nch, "route_binary.pgm");

	free_bmatrix(I, nrl, nrh, ncl, nch);
	free_bmatrix(binary, nrl, nrh, ncl, nch);
	return 0;
}
inline double geodist(double long1, double lat1, double long2, double lat2)
{
    double radLat1 = rad(lat1);
    double radLat2 = rad(lat2);
    double a = radLat1 - radLat2;
    double b = rad(long1) - rad(long2);
    double s = 2 * asin(sqrt(pow(sin(a / 2), 2) + cos(radLat1) * cos(radLat2) * pow(sin(b / 2), 2)));
    return s * EARTH_RADIUS * 1000.0;
}
Beispiel #9
0
Point MathHelper::calcEndPoint(const Point &startPoint, float angle, float length)
{
  Point endPoint;

  endPoint.setX(startPoint.x() + length * cos(rad(angle)));
  endPoint.setY(startPoint.y()+ length * sin(rad(angle)));

  return endPoint;
}
Beispiel #10
0
void resetCamera() {
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    // página 19 http://professor.unisinos.br/ltonietto/jed/pgr/CameraSintetica.pdf
    gluLookAt(
              currentPosition.x, currentPosition.y, currentPosition.z,
              currentPosition.x + cos(rad(angleH)), sin(rad(angleV)), currentPosition.z + sin(rad(angleH)),
              0, 1, 0
              );
}
Beispiel #11
0
void animate_havoc_external_wipers (object_3d_instance *inst3d)
{
	object_3d_sub_object_search_data
		search;

	////////////////////////////////////////
	//
	// pilot's wipers
	//
	////////////////////////////////////////

	search.search_depth = 0;
	search.search_object = inst3d;
	search.sub_object_index = OBJECT_3D_SUB_OBJECT_WIPER_ARM_PILOT;

	if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND)
	{
		search.result_sub_object->relative_roll = wiper_position * (rad (65.3756) / MAX_WIPER_POSITION);
	}

	search.search_depth = 0;
	search.search_object = inst3d;
	search.sub_object_index = OBJECT_3D_SUB_OBJECT_WIPER_BLADE_PILOT;

	if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND)
	{
		search.result_sub_object->relative_roll = (wiper_position * (rad (-74.7756) / MAX_WIPER_POSITION)) + rad (4.7);
	}

	////////////////////////////////////////
	//
	// co-pilot's wipers
	//
	////////////////////////////////////////

	search.search_depth = 0;
	search.search_object = inst3d;
	search.sub_object_index = OBJECT_3D_SUB_OBJECT_WIPER_ARM_COPILOT;

	if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND)
	{
		search.result_sub_object->relative_roll = wiper_position * (rad (90.0) / MAX_WIPER_POSITION);
	}

	search.search_depth = 0;
	search.search_object = inst3d;
	search.sub_object_index = OBJECT_3D_SUB_OBJECT_WIPER_BLADE_COPILOT;

	if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND)
	{
		search.result_sub_object->relative_roll = (wiper_position * (rad (-100.0) / MAX_WIPER_POSITION)) + rad (5.0);
	}
}
Beispiel #12
0
void update_vector_main_rotor_dynamics (void)
{

	float
		rotor_roll,
		rotor_pitch,
		cyclic_x,
		cyclic_y,
		collective,
		blade_pitch;

	// calculate blade pitch 0->5 Degs. collective = blade_pitch^3

	collective = current_flight_dynamics->input_data.collective.value;

	blade_pitch = pow (fabs (collective), (float) (1.0 / 3.0)) * (current_flight_dynamics->main_blade_pitch.max / 4.64);

	current_flight_dynamics->main_blade_pitch.value = blade_pitch;

	current_flight_dynamics->main_blade_pitch.value = bound (
																current_flight_dynamics->main_blade_pitch.value,
																current_flight_dynamics->main_blade_pitch.min,
																current_flight_dynamics->main_blade_pitch.max);

	// calculate 'Tip Plane Path' roll and pitch

	// roll

	cyclic_x = current_flight_dynamics->input_data.cyclic_x.value;

	rotor_roll = rad (cyclic_x / (current_flight_dynamics->input_data.cyclic_x.max / deg (current_flight_dynamics->main_rotor_roll_angle.max)));

	current_flight_dynamics->main_rotor_roll_angle.value = rotor_roll;

	current_flight_dynamics->main_rotor_roll_angle.value = bound (
																current_flight_dynamics->main_rotor_roll_angle.value,
																current_flight_dynamics->main_rotor_roll_angle.min,
																current_flight_dynamics->main_rotor_roll_angle.max);

	// pitch

	cyclic_y = current_flight_dynamics->input_data.cyclic_y.value;

	rotor_pitch = -rad (cyclic_y / (current_flight_dynamics->input_data.cyclic_y.max / deg (current_flight_dynamics->main_rotor_pitch_angle.max)));

	current_flight_dynamics->main_rotor_pitch_angle.value = rotor_pitch;

	current_flight_dynamics->main_rotor_pitch_angle.value = bound (
																current_flight_dynamics->main_rotor_pitch_angle.value,
																current_flight_dynamics->main_rotor_pitch_angle.min,
																current_flight_dynamics->main_rotor_pitch_angle.max);
}
Beispiel #13
0
 void Plan13::footprintOctagon(float *points, float SLATin, float SLONin, float REin, float RSin) {
	//static float points[16];
	Serial.print("SLAT: ");
	Serial.print(SLATin);
	Serial.print(", SLON: ");
	Serial.print(SLONin);
	Serial.print(", RE: ");
	Serial.print(REin);
	Serial.print(", RS: ");
	Serial.println(RSin);
	float srad = acos(REin/RSin); // Beta in Davidoff diag. 13.2, this is in rad
	Serial.print("srad: ");
	Serial.println(srad);
	float cla= cos(rad(SLATin));
	float sla = sin(rad(SLATin));
	float clo = cos(rad(SLONin));
	float slo = sin(rad(SLONin));
	float sra = sin(srad);
	float cra = cos(srad);
	for (int i = 0; i < 16; i = i +2) {
		float a = 2 * M_PI * i / 16;
		Serial.print("\ta: ");
		Serial.println(a);
		float X = cra;
		Serial.print("\t first X: ");
		Serial.println(X);
		Serial.print("\t first Y: ");
		float Y = sra*sin(a);
		Serial.println(Y);
		float Z = sra*cos(a);
		Serial.print("\t first Z: ");
		Serial.println(Z);
		float x = X*cla - Z*sla;
		float y = Y;
		float z = X*sla + Z*cla;
		X = x*clo - y*slo;
		Serial.print("\tX: ");
		Serial.println(X);
		Y = x*slo + y*clo;
		Serial.print("\tY: ");
		Serial.println(Y);
		Z = z; 
		Serial.print("\tZ: ");
		Serial.println(Z);
		points[i] = deg(FNatn(Y,X));
		Serial.print("\t Long: ");
		Serial.print(points[i]);
		points[i+1] = deg(asin(Z));
		Serial.print("\t Lat: ");
		Serial.println(points[i+1]);
	}
}
Beispiel #14
0
static void fast_rotate_air_radar_scan_datum_right (void)
{
	air_radar.scan_datum += rad (90.0);

	air_radar.sweep_offset -= rad (90.0);

	if (air_radar.scan_datum > rad (180.0))
	{
		air_radar.scan_datum -= rad (360.0);
	}

	limit_radar_sweep (&air_radar);
}
Beispiel #15
0
static void rotate_air_radar_scan_datum_right (void)
{
	air_radar.scan_datum += APACHE_AIR_RADAR_SCAN_DATUM_ROTATE_STEP;

	air_radar.sweep_offset -= APACHE_AIR_RADAR_SCAN_DATUM_ROTATE_STEP;

	if (air_radar.scan_datum > rad (180.0))
	{
		air_radar.scan_datum -= rad (360.0);
	}

	limit_radar_sweep (&air_radar);
}
Beispiel #16
0
static void fast_rotate_air_radar_scan_datum_left (void)
{
	air_radar.scan_datum -= rad (90.0);

	air_radar.sweep_offset += rad (90.0);

	if (air_radar.scan_datum < rad (-180.0))
	{
		air_radar.scan_datum += rad (360.0);
	}

	limit_radar_sweep (&air_radar);
}
Beispiel #17
0
void initialise_viper_hms (void)
{
	if (get_global_simple_avionics ())
	{
		hms_max_visual_range		= 5000.0;
		hms_max_field_of_view	= rad (45.0);
	}
	else
	{
		hms_max_visual_range		= 2500.0;
		hms_max_field_of_view	= rad (45.0);
	}
};
Beispiel #18
0
double getDistance(double dlat1,double dlng1,double dlat2,double dlng2)
{
	double radlat1 = rad(dlat1);
	double radlat2 = rad(dlat2);

	double a = radlat1-radlat2;
	double b = rad(dlng1)-rad(dlng2);

	double s = 2*asin(sqrt(pow(sin(a/2),2) +cos(radlat1)*cos(radlat2)*pow(sin(b/2),2)));
	s = s*6378.137;
	s = round(s*10000)/10000;
	return s;
}
Beispiel #19
0
void update_viper_hms (void)
{
	if (get_global_simple_avionics ())
	{
		hms_max_visual_range		= 5000.0;
		hms_max_field_of_view	= rad (45.0);
	}
	else
	{
		hms_max_visual_range		= 2500.0;
		hms_max_field_of_view	= rad (45.0);
	}

	////////////////////////////////////////

	while (single_target_acquisition_system_select_next_target_key)
	{
		select_next_hms_target ();

		single_target_acquisition_system_select_next_target_key--;
	}

	////////////////////////////////////////

	while (single_target_acquisition_system_select_previous_target_key)
	{
		select_previous_hms_target ();

		single_target_acquisition_system_select_previous_target_key--;
	}

// Jabberwock 031107 Designated targets
	
	while (single_target_acquisition_system_select_next_designated_key)
	{
		select_next_designated_hms_target ();

		single_target_acquisition_system_select_next_designated_key--;
	}

	////////////////////////////////////////

	while (single_target_acquisition_system_select_previous_designated_key)
	{
		select_previous_designated_hms_target ();

		single_target_acquisition_system_select_previous_designated_key--;
	}	

// Jabberwock 031107 ends	
}
void GLWidget::pickPoint(int mouse_x, int mouse_y, double *scene_x, double *scene_y) {
  double cx = window_width / 2.0;
  double cy = window_height / 2.0;
  double pan = rad(-90.0 - camera_pose.pan);
  double tilt = rad(90.0 - camera_pose.tilt);
  double d = camera_pose.distance;
  double f = cy / tan(rad(camera_fov / 2.0));

  double px = (mouse_x - cx) * cos(tilt) * d / (cos(tilt) * f + sin(tilt) * mouse_y - sin(tilt) * cy);
  double py = -(mouse_y - cy) * d / (cos(tilt) * f + sin(tilt) * mouse_y - sin(tilt) * cy);

  // rotate by pan, add offset
  *scene_x = px * cos(pan) + py * sin(pan) + camera_pose.x_offset;
  *scene_y = -px * sin(pan) + py * cos(pan) + camera_pose.y_offset;
}
Beispiel #21
0
static double distance(double lat1,double lon1,double lat2,double lon2)
{
	double dlat = fabs(rad(lat1) - rad(lat2));
	double dlon = fabs(rad(lon1) - rad(lon2));
	double a,c,d;
	//printf("===%f,%f\n",dlat,dlon);
	a = sin(dlat / 2) * sin(dlat / 2) + cos(lat1) * cos(lat2) * sin(dlon / 2) * sin(dlon / 2);
	//printf("a===%f\n",a);
	a=fabs(a);
	c = 2 * atan2(sqrt(a), sqrt(fabs(1 - a)));
	//printf("c===%f\n",c);
	d = EARTH * c;
	printf("%.6f\n",d);
    return d;
}
Beispiel #22
0
void iac::initAC (void) {
  nr_double_t a = getPropertyDouble ("I");
  nr_double_t p = getPropertyDouble ("Phase");
  nr_complex_t i = polar (a, rad (p));
  allocMatrixMNA ();
  setI (NODE_1, +i); setI (NODE_2, -i);
}
Beispiel #23
0
static float get_ballistic_weapon_drop(entity_sub_types weapon_sub_type)
{
#define MAX_RANGE 4000.0
	static float
		angle_of_drop = 0.0;

	float
		time_of_flight,
		triangulated_range,
		range_diff,
		height = current_flight_dynamics->radar_altitude.value,
		pitch = current_flight_dynamics->pitch.value;

	if (get_time_acceleration() != TIME_ACCELERATION_PAUSE)
	{
		if (pitch > (angle_of_drop + rad(0.05)) || height < 2.0)
			triangulated_range = MAX_RANGE;
		else
			triangulated_range = bound(height / tan(-pitch + angle_of_drop), 0.0, MAX_RANGE);

		range_diff = triangulated_range - hud_aim_range;
		// move the aiming range in gradual steps, so as not to come into a oscilating
		// state where it continousely overcorrects in alternating directions
		hud_aim_range += 0.25 * range_diff;

		if (get_ballistic_pitch_deflection(weapon_sub_type, hud_aim_range, pitch, &angle_of_drop, &time_of_flight, FALSE, TRUE))
			angle_of_drop -= pitch;
		else
			angle_of_drop = 0.0;
	}


	hud_aim_range;
	return angle_of_drop;
}
Beispiel #24
0
static void initialise_hms_gun_pipper (void)
{
	int
		i;

	float
		theta,
		sin_theta,
		cos_theta;

	theta = rad(0);

	for (i = 0; i < NUM_GUN_PIPPER_POINTS; i++)
	{
		sin_theta = sin (theta);
		cos_theta = cos (theta);

		gun_pipper_points[i][0] = sin_theta * GUN_PIPPER_SIZE;
		gun_pipper_points[i][1] = cos_theta * GUN_PIPPER_SIZE;
		gun_pipper_points2[i][0] = sin_theta * GUN_PIPPER_SIZE2;
		gun_pipper_points2[i][1] = cos_theta * GUN_PIPPER_SIZE2;

		theta += GUN_PIPPER_ANGULAR_STEP_SIZE;
	}
}
Beispiel #25
0
int QilexDoc::doc_new_kinematic_hand(ct_new_kinematic_chain *data)
{
   int error = 0;
   int tipus = 0;
   void * buffer ; //char *buffer;
   char *buftemp = (char*)malloc(1024);

   SoOutput out;

   size_t sizeModel = 0;

   SoSeparator *kinechain = new SoSeparator;
   SoSeparator *kinetest = new SoSeparator;

   Rchain_hand *kineengine = new Rchain_hand();

   SoTransform *pos_rot = new SoTransform;
   SbVec3f joinax;

   joinax.setValue(SbVec3f(data->x,data->y,data->z));
   pos_rot->translation.setValue(joinax);
   pos_rot->rotation.setValue(SbVec3f(data->axeX, data->axeY, data->axeZ), (float) rad((double) data->angle));

   kinechain = readFile(data->QsModelFile.latin1(), tipus);

   if (kinechain == NULL) // no object read
   { return 1; }
   else  // ok, there's no object with the same name
   {
      error = kineengine->init_dat(data->QsDatFile.latin1()); //

      if (error == 0)
      {
         kinechain->ref();
         kinetest = (SoSeparator*)SoNode::getByName(data->QsName.latin1());

         if (kinetest==NULL)
         {
            //we need to put it in a buffer to write the xml file
            // if is Ok
            SoOutput out;
            out.setBuffer(buftemp, 1024, reallocCB);

            SoWriteAction wa1(&out);
            wa1.apply(kinechain);

            out.getBuffer(buffer, sizeModel);

            kinechain->insertChild(pos_rot, 0);
         }
         error = doc_insert_kinematic_hand(kineengine, kinechain);
      }
   }

   if (error==0)
   {
      writeXML_kineelement((char *)buffer, sizeModel, tipus, data, kineengine);
   }
   return error;
}
Beispiel #26
0
void BallMovement::bounce(bool collision)
{
    fix_position();

    float angle = rad(instance->direction * 11.25f);
    float found_a = -1.0f;
    for (float a = 0.0f; a < (CHOW_PI*2.0f); a += (CHOW_PI*2.0f) / 16.0f) {
        float x_move = 10.0f * cos(angle + a);
        float y_move = -10.0f * sin(angle + a);

        int x = instance->x + x_move;
        int y = instance->y + y_move;

        if (!test_position(x, y)) {
            found_a = a;
            break;
        }
    }

    if (found_a == -1.0f) {
        instance->set_direction((instance->direction + 16) % 32, false);
        return;
    }

    angle += found_a * 2.0f;
    if (angle > 2.0 * CHOW_PI)
        angle -= 2.0 * CHOW_PI;

    instance->set_direction(deg(angle) / 11.25f, false);
}
Beispiel #27
0
int RadixSort::Sort(Array &array) const
{
	int maxRadix = 100; 
	std::vector<int> rad(array.Size()); // for stroring mod
	std::vector<int> tmp(array.Size()); // 

	for(int m=1; m <= maxRadix; m*=10)
	{
		for(int i=0; i < array.Size();i++)
		{
			rad[i] = (array[i] / m) % 10;
		}
		
		int k = 0;
		for(int i=0; i < 10; i++)
		{
			for(int j=0; j < array.Size(); j++)
			{
				if(rad[j] == i)
				{
					tmp[k++] = array[j]; // copy array to tmp based on 'mod'
				}
			}
		}
		
		for(int i=0; i< array.Size(); i++)
		{
			array[i] = tmp[i];   // copy tmp back to array
		}
		// array.Print("->");
	}
	return 0;
}
Beispiel #28
0
int main() {
    bool sieve[MAX];
    memset(sieve, true, sizeof(sieve));
    sieve[0] = false;
    sieve[1] = false;
    int prime = 2;
    for (int i = 0; i * i < MAX; ++i) {
        del_mult(prime, sieve);
        prime = next_prime(prime, sieve);
    }

    std::vector<int> primes;
    for (int i = 0; i < MAX; ++i) {
        if (sieve[i])
            primes.push_back(i);
    }

    std::vector<std::pair<int, int>> pairs;
    for (int i = 1; i <= 100000; ++i) {
        pairs.push_back(std::make_pair(i, rad(i, primes)));
    }

    std::sort(pairs.begin(), pairs.end(), less_than);
    std::cout << pairs[9999].first << std::endl;
    return 0;
}
void Campus::Shake(){
	if (ShakeTime > 0){
		ShakeTime--;
		std::uniform_real_distribution<float> rad(0.0f, 1.0f);

		std::mt19937 mtRand{ std::random_device()() };

		ShakeVar.x = rad(mtRand)*SHAKE_POWER - SHAKE_POWER / 2;
		ShakeVar.y = rad(mtRand)*SHAKE_POWER - SHAKE_POWER / 2;
	}
	else{
		ShakeVar.x = 0;
		ShakeVar.y = 0;
		ShakeTime = 0;
	}
}
Beispiel #30
0
void hybrid::initAC (void) {
  nr_double_t  k = 2.0 * M_SQRT2;
  nr_complex_t p = polar (1.0, rad (getPropertyDouble ("phi")));
  nr_complex_t d = 2.0 * p * (p - 4.0) - 1.0;
  nr_complex_t y;

  setVoltageSources (0);
  allocMatrixMNA ();
  d *= getPropertyDouble ("Zref");

  y = (-6.0*p*p + 8.0*p - 1.0) / d;
  setY (NODE_1, NODE_1, y); setY (NODE_3, NODE_3, y);

  y = (-2.0*p*p + 8.0*p - 5.0) / d;
  setY (NODE_2, NODE_2, y); setY (NODE_4, NODE_4, y);

  y = 2.0*k * (p * (p - 1.0) - 0.5) / d;
  setY (NODE_1, NODE_3, y); setY (NODE_3, NODE_1, y);

  y = k * (p - 2.0) / d;
  setY (NODE_2, NODE_4, y); setY (NODE_4, NODE_2, y);

  y = k * (-2.0*p + 1.0) / d;
  setY (NODE_1, NODE_4, y); setY (NODE_4, NODE_1, y);
  setY (NODE_2, NODE_3, y); setY (NODE_3, NODE_2, y);

  y = (4.0*p + 4.0) / d;
  setY (NODE_1, NODE_2, y); setY (NODE_2, NODE_1, y);
  setY (NODE_3, NODE_4, y); setY (NODE_4, NODE_3, y);
}