您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ vector_dot函数代码示例

51自学网 2021-06-03 09:37:15
  C++
这篇教程C++ vector_dot函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中vector_dot函数的典型用法代码示例。如果您正苦于以下问题:C++ vector_dot函数的具体用法?C++ vector_dot怎么用?C++ vector_dot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了vector_dot函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: vector

/*Returns the angular difference in the horizontal plane between the"from" vector and north, in degrees.Description of heading algorithm:Shift and scale the magnetic reading based on calibration data to findthe North vector. Use the acceleration readings to determine the Upvector (gravity is measured as an upward acceleration). The crossproduct of North and Up vectors is East. The vectors East and Northform a basis for the horizontal plane. The From vector is projectedinto the horizontal plane and the angle between the projected vectorand horizontal north is returned. */float LSM303_heading(){	vector_float from = {0,0,1};			//Z axis forward	vector_float temp_m = {LSM303_m.x, LSM303_m.y, LSM303_m.z};	vector_float temp_a = {LSM303_a.x, LSM303_a.y, LSM303_a.z};	// subtract offset (average of min and max) from magnetometer readings	temp_m.x -= ((float)m_min.x + m_max.x) / 2;	temp_m.y -= ((float)m_min.y + m_max.y) / 2;	temp_m.z -= ((float)m_min.z + m_max.z) / 2;	// compute E and N	vector_float E;	vector_float N;	vector_cross(&temp_m, &temp_a, &E);	vector_normalize(&E);	vector_cross(&temp_a, &E, &N);	vector_normalize(&N);	// compute heading	float heading = atan2(vector_dot(&E, &from), vector_dot(&N, &from)) * 180 / M_PI;	if (heading < 0) heading += 360;	DEBUGPRINT("Heading: %0.1f/n", heading);	return heading;}
开发者ID:wda2945,项目名称:Fido,代码行数:40,


示例2: separate_by_axis

static int separate_by_axis(vector_s axis, lua_Number hw1, const body_s *body1,                            const body_s *body2, vector_s *out){    //printf("axiss = %lf, %lf/n", axis.x, axis.y);    lua_Number overlap =        vector_dot(body1->pos, axis) + hw1 +         halfwidth_along_axis(            vector_neg(vector_rotate_from(axis, body2->facing)),            body2->poly) -        vector_dot(body2->pos, axis);    //printf("overlap = %lf - %lf + %lf - %lf = %lf/n",    //    vector_dot(body1->pos, axis), hw1,    //    halfwidth_along_axis(    //        vector_neg(vector_rotate_from(axis, body2->facing)),    //        body2->poly),    //    vector_dot(body2->pos, axis), overlap);    if(overlap <= 0) return 0;    vector_s correction =        vector_mul(axis, overlap/vector_dot(axis, axis));    if(correction.x == 0 && correction.y == 0) return 0;    //printf("correction = %lf, %lf/n", correction.x, correction.y);    if(vector_dot(correction, correction) < vector_dot(*out, *out))        *out = correction;    return 1;}
开发者ID:henkboom,项目名称:dokidoki-support,代码行数:27,


示例3: lightColor

/* * Calculate light color */color lightColor(const intersection *inter, const ray *srcRay) {	vec3 v = vector_normalized(vector_float_mul(-1.0f, srcRay->dir));	color cD = BLACK, refCoef = reflectCoef(inter->mat.reflect_coef, inter->normal, srcRay->dir);	// For each light calculate and sum color	for (int k = 0; k < num_lights; ++k) {		vec3 l = vector_minus(lights[k].position, inter->position);		float normL = vector_norm(l);		l = vector_normalized(l);		// Look for object between light source and current intersection		ray objectRay; // Ray from object to light		ray_init(&objectRay, inter->position, l, EPSILON, normL, 0);		float interFound = 0.0f;		for (int i = 0; i < object_count; ++i) {			interFound += interDist(&objectRay, &(scene[i]));		}		if (!interFound) {			vec3 h = vector_normalized(vector_add(l, v));			float sc_nl = clamp(vector_dot(inter->normal, l), 0.0f, 1.0f);			float sc_hn = clamp(vector_dot(h, inter->normal), 0.0f, 1.0f);			cD = vector_add(cD,					vector_vec_mul(lights[k].col,							vector_float_mul(sc_nl,									(vector_add(vector_float_mul(1 / M_PI, inter->mat.kd),											(vector_float_mul(pow(sc_hn, inter->mat.shininess), vector_float_mul(((inter->mat.shininess + 8) / (8 * M_PI)), refCoef))))))));		}	}	return cD;}
开发者ID:Spooky4672,项目名称:RayTracer,代码行数:31,


示例4: line_segments_intersect

bool line_segments_intersect(vector_float2 p1, vector_float2 p2, vector_float2 q1, vector_float2 q2){    vector_float2 r = {p2.x - p1.x, p2.y - p1.y};    vector_float2 s = {q2.x - q1.x, q2.y - q1.y};    vector_float2 q_minus_p = {q1.x - p1.x, q1.y - p1.y};    float r_cross_s = vector_cross(r, s).z;    float q_minus_p_cross_r = vector_cross(q_minus_p, r).z;    float q_minus_p_cross_s = vector_cross(q_minus_p, s).z;    if (q_minus_p_cross_r == 0 && r_cross_s == 0) {        // The lines are colinear        float magnitude_r = vector_length(r);        float s_dot_r = vector_dot(s, r);        float t0 = vector_dot(q_minus_p, r) / magnitude_r;        float t1 = t0 + s_dot_r / magnitude_r;        return ((t0 >= 0 && t0 <= 1) || (t1 >= 0 && t1 <= 1));    } else if (r_cross_s == 0 && q_minus_p_cross_r != 0) {        // The lines are parallel and non-intersecting        return false;    } else if (r_cross_s != 0) {        float t = q_minus_p_cross_s / r_cross_s;        float u = q_minus_p_cross_r / r_cross_s;        // Normally you'd want to test for 0 <= t <= 1 && 0 <= u <= 1, but        // that would mean that two lines that share the same endpoint are        // marked as intersecting, which isn't what we want for our use case.        return t > 0 && t < 1 && u > 0 && u < 1;    }    return false;}
开发者ID:mohiji,项目名称:JLFGameplayKit,代码行数:32,


示例5: START_TEST

END_TESTSTART_TEST(test_vector_three) {  u32 i, t;  seed_rng();  for (t = 0; t < LINALG_NUM; t++) {    double A[3], B[3], C[3], tmp[3];    double D, E, F, norm;    for (i = 0; i < 3; i++) {      A[i] = mrand / 1e20;      B[i] = mrand / 1e20;      C[i] = mrand / 1e20;    }    /* Check triple product identity */    vector_cross(A, B, tmp);    D = vector_dot(3, C, tmp);    vector_cross(B, C, tmp);    E = vector_dot(3, A, tmp);    vector_cross(C, A, tmp);    F = vector_dot(3, B, tmp);    norm = (vector_norm(3, A) + vector_norm(3, B) + vector_norm(3, C))/3;    fail_unless(fabs(E - D) < LINALG_TOL * norm,                "Triple product failure between %lf and %lf",                D, E);    fail_unless(fabs(E - F) < LINALG_TOL * norm,                "Triple product failure between %lf and %lf",                E, F);    fail_unless(fabs(F - D) < LINALG_TOL * norm,                "Triple product failure between %lf and %lf",                F, D);  }}
开发者ID:mjbastian,项目名称:libswiftnav,代码行数:34,


示例6: calcHeading

// Calculate the headingfloat calcHeading(float *from, const Accelerometer *acc, const Magnetometer *mag){    // Change values with values from calibration tests...	int16_t min[] = { 32767, 32767, 32767 };	int16_t max[] = { -32767, -32767, -32767 };	float temp_m[] = { mag->x, mag->y, mag->z };	float temp_a[] = { acc->x, acc->y, acc->z };	// Initialize east and north vector	float east[] = {0, 0, 0};    float north[] = {0, 0, 0};    int i;	for(i = 0; i < 3; i ++)		temp_m[i] -= (min[i]+max[i])/2;	// Calculate North and East vectors	vector_cross(temp_m, temp_a, east);	vector_normalize(east);	vector_cross(temp_a, east, north);	vector_normalize(north);	// Calculate angular difference	float heading = atan2(vector_dot(east, from), vector_dot(north,from))*180/M_PI;	if (heading < 0)		heading += 360;	return heading;}
开发者ID:agpaoa,项目名称:digital_compass,代码行数:32,


示例7: temp_a

// Returns the angular difference in the horizontal plane between the// From vector and North, in degrees.//// Description of heading algorithm:// Shift and scale the magnetic reading based on calibration data to// to find the North vector. Use the acceleration readings to// determine the Up vector (gravity is measured as an upward// acceleration). The cross product of North and Up vectors is East.// The vectors East and North form a basis for the horizontal plane.// The From vector is projected into the horizontal plane and the// angle between the projected vector and north is returned.int LSM303::heading(vector from){    // shift and scale    m_dataMag.x = (m_dataMag.x - m_minMag.x) / (m_maxMag.x - m_minMag.x) * 2 - 1.0;    m_dataMag.y = (m_dataMag.y - m_minMag.y) / (m_maxMag.y - m_minMag.y) * 2 - 1.0;    m_dataMag.z = (m_dataMag.z - m_minMag.z) / (m_maxMag.z - m_minMag.z) * 2 - 1.0;    vector temp_a(m_dataAcc);    vector temp_m(m_dataMag);    // normalize    vector_normalize(temp_a);    //vector_normalize(&m);    // compute E and N    vector E;    vector N;    vector_cross(temp_m, temp_a, E);    vector_normalize(E);    vector_cross(temp_a, E, N);    // compute heading    int heading = round(atan2(vector_dot(E, from), vector_dot(N, from)) * 180 / M_PI);    if (heading < 0) heading += 360;  return heading;}
开发者ID:wenndemann,项目名称:blabot,代码行数:37,


示例8: vector

/*Returns the angular difference in the horizontal plane between the"from" vector and north, in degrees.Description of heading algorithm:Shift and scale the magnetic reading based on calibration data to findthe North vector. Use the acceleration readings to determine the Upvector (gravity is measured as an upward acceleration). The crossproduct of North and Up vectors is East. The vectors East and Northform a basis for the horizontal plane. The From vector is projectedinto the horizontal plane and the angle between the projected vectorand horizontal north is returned.*/float Compass::getHeading(){  vector<int> from = (vector<int>){0, -1, 0};    compass->read();    vector<int32_t> temp_m = {compass->magData.x, compass->magData.y, compass->magData.z};  vector<int32_t> temp_a = {compass->accelData.x, compass->accelData.y, compass->accelData.z};  // subtract offset (average of min and max) from magnetometer readings  temp_m.x -= ((int32_t)calMin.x + calMax.x) / 2;  temp_m.y -= ((int32_t)calMin.y + calMax.y) / 2;  temp_m.z -= ((int32_t)calMin.z + calMax.z) / 2;  // compute E and N  vector<float> E;  vector<float> N;  vector_cross(&temp_m, &temp_a, &E);  vector_normalize(&E);  vector_cross(&temp_a, &E, &N);  vector_normalize(&N);  // compute heading  float heading = atan2(vector_dot(&E, &from), vector_dot(&N, &from)) * RAD2DEG;  // correcting for mounting direction  heading -= 90.0;  if (heading < 0) heading += 360;  return heading;}
开发者ID:JohnPetersen,项目名称:Seeker_Hats,代码行数:43,


示例9: plane_intersect

bool plane_intersect(plane_t p, vector_t ray_start, vector_t ray_direction, vector_t* hit){    float denominator = vector_dot(p.normal, ray_direction);    if (denominator == 0)        return false;    float t = vector_dot(p.normal, vector_sub(p.point, ray_start)) / denominator;    if (t < 0.0)        return false;    *hit = vector_add(ray_start, vector_scale(ray_direction, t));    return true;}
开发者ID:abau171,项目名称:shinythings,代码行数:11,


示例10: interDistSphere

float interDistSphere(const ray *r, const object *obj) {	vec3 ominusc = vector_minus(r->orig, obj->center);	float a = vector_dot(r->dir, r->dir);	float b = 2.0f * vector_dot(r->dir, ominusc);	float c = (vector_dot(ominusc, ominusc) - obj->radius * obj->radius);	float delta = b * b - 4.0f * a * c;	if (delta > 0.0f) {		float sqrtDelta = sqrt(delta);		float t0 = (-b - sqrtDelta) / (2.0f * a), t1 = (-b + sqrtDelta) / (2.0f * a);		return t0 > t1 ? t1 : t0;	}	return -1.0f;}
开发者ID:Spooky4672,项目名称:RayTracer,代码行数:13,


示例11: intersection_plan

int			intersection_plan(t_plan *plan, t_ray *ray, double *t){	double		alpha;	alpha = vector_dot(plan->normal, ray->o) + plan->constante;	alpha = -alpha;	alpha = alpha / vector_dot(plan->normal, ray->d);	if ((alpha > 0.1) && (alpha < *t))	{		*t = alpha;		return (0);	}	return (-1);}
开发者ID:ebaudet,项目名称:Raytracer,代码行数:14,


示例12: vector_mag

double MATHNS::angle(std::vector<double> u, std::vector<double> v){    double um = vector_mag(u);    double vm = vector_mag(v);    double dot = vector_dot(u,v);    return acos(dot/(um*vm));}
开发者ID:jmgonza6,项目名称:crystal-builder,代码行数:7,


示例13: sphere_intersect

/** * sphere_intersect - Check ray intersection with a sphere object. * @sphere: Pointer to sphere object * @ray:    Pointer to normalized ray object * * This function will test if a ray, @ray, will intersect a sphere, @sphere. * Imaging a ray R with origin at E and direction V intersecting a sphere with * center O and radius r. The intersection point will be detnoted P. A triangle * E-O-A, where A is a right angle can be drawn. The E-O side has length c, E-A * has length v and O-A has length b. See figure 1. * *                       ...---o O                               ...---o O *              c  ...---      |                        r  ...---      | *           ...---            | b                   ...---            | b *     ...---                  |               ...---                  | *  E o------------------------o A          P o------------------------o A *                 v                                       d *  fig 1.                                  fig 2. * * The v side will then have the same direction as V and i.e. will represent a * bit of the ray R. * Pythagorean theorem gives: *    v
C++ vector_free函数代码示例
C++ vector_destroy函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。