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

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

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

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

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

示例1: maskrasterize_spline_differentiate_point_outset

static void maskrasterize_spline_differentiate_point_outset(float (*diff_feather_points)[2], float (*diff_points)[2],                                                            const unsigned int tot_diff_point, const float ofs,                                                            const bool do_test){	unsigned int k_prev = tot_diff_point - 2;	unsigned int k_curr = tot_diff_point - 1;	unsigned int k_next = 0;	unsigned int k;	float d_prev[2];	float d_next[2];	float d[2];	const float *co_prev;	const float *co_curr;	const float *co_next;	const float ofs_squared = ofs * ofs;	co_prev = diff_points[k_prev];	co_curr = diff_points[k_curr];	co_next = diff_points[k_next];	/* precalc */	sub_v2_v2v2(d_prev, co_prev, co_curr);	normalize_v2(d_prev);	for (k = 0; k < tot_diff_point; k++) {		/* co_prev = diff_points[k_prev]; */ /* precalc */		co_curr = diff_points[k_curr];		co_next = diff_points[k_next];		/* sub_v2_v2v2(d_prev, co_prev, co_curr); */ /* precalc */		sub_v2_v2v2(d_next, co_curr, co_next);		/* normalize_v2(d_prev); */ /* precalc */		normalize_v2(d_next);		if ((do_test == FALSE) ||		    (len_squared_v2v2(diff_feather_points[k], diff_points[k]) < ofs_squared))		{			add_v2_v2v2(d, d_prev, d_next);			normalize_v2(d);			diff_feather_points[k][0] = diff_points[k][0] + ( d[1] * ofs);			diff_feather_points[k][1] = diff_points[k][1] + (-d[0] * ofs);		}		/* use next iter */		copy_v2_v2(d_prev, d_next);		/* k_prev = k_curr; */ /* precalc */		k_curr = k_next;		k_next++;	}}
开发者ID:BlueLabelStudio,项目名称:blender,代码行数:60,


示例2: check_corners

static bool check_corners(float corners[4][2]){  int i, next, prev;  float cross = 0.0f;  for (i = 0; i < 4; i++) {    float v1[2], v2[2], cur_cross;    next = (i + 1) % 4;    prev = (4 + i - 1) % 4;    sub_v2_v2v2(v1, corners[i], corners[prev]);    sub_v2_v2v2(v2, corners[next], corners[i]);    cur_cross = cross_v2v2(v1, v2);    if (fabsf(cur_cross) <= FLT_EPSILON) {      return false;    }    if (cross == 0.0f) {      cross = cur_cross;    }    else if (cross * cur_cross < 0.0f) {      return false;    }  }  return true;}
开发者ID:dfelinto,项目名称:blender,代码行数:29,


示例3: v2_quad_corners_to_mat4

/* Use 2D quad corners to create a matrix that set * a [-1..1] quad at the right position. */static void v2_quad_corners_to_mat4(float corners[4][2], float r_mat[4][4]){  unit_m4(r_mat);  sub_v2_v2v2(r_mat[0], corners[1], corners[0]);  sub_v2_v2v2(r_mat[1], corners[3], corners[0]);  mul_v2_fl(r_mat[0], 0.5f);  mul_v2_fl(r_mat[1], 0.5f);  copy_v2_v2(r_mat[3], corners[0]);  add_v2_v2(r_mat[3], r_mat[0]);  add_v2_v2(r_mat[3], r_mat[1]);}
开发者ID:dfelinto,项目名称:blender,代码行数:13,


示例4: len_manhattan_v2v2

MINLINE float len_manhattan_v2v2(const float a[2], const float b[2]){	float d[2];	sub_v2_v2v2(d, b, a);	return len_manhattan_v2(d);}
开发者ID:BlueLabelStudio,项目名称:blender,代码行数:7,


示例5: gp_point_xy_to_3d

/* Project screenspace coordinates to 3D-space * NOTE: We include this as a utility function, since the standard method *       involves quite a few steps, which are invariably always the same *       for all GPencil operations. So, it's nicer to just centralise these. * WARNING: Assumes that it is getting called in a 3D view only */bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen_co[2], float r_out[3]){	View3D *v3d = gsc->sa->spacedata.first;	RegionView3D *rv3d = gsc->ar->regiondata;	float *rvec = ED_view3d_cursor3d_get(scene, v3d);	float ref[3] = {rvec[0], rvec[1], rvec[2]};	float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);		float mval_f[2], mval_prj[2];	float dvec[3];		copy_v2_v2(mval_f, screen_co);		if (ED_view3d_project_float_global(gsc->ar, ref, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {		sub_v2_v2v2(mval_f, mval_prj, mval_f);		ED_view3d_win_to_delta(gsc->ar, mval_f, dvec, zfac);		sub_v3_v3v3(r_out, rvec, dvec);				return true;	}	else {		zero_v3(r_out);				return false;	}}
开发者ID:Brachi,项目名称:blender,代码行数:32,


示例6: len_squared_v2v2

MINLINE float len_squared_v2v2(const float a[2], const float b[2]){	float d[2];	sub_v2_v2v2(d, b, a);	return dot_v2v2(d, d);}
开发者ID:BlueLabelStudio,项目名称:blender,代码行数:7,


示例7: marker_unified_to_search_pixel

static void marker_unified_to_search_pixel(int frame_width, int frame_height,                                           const MovieTrackingMarker *marker,                                           const float marker_unified[2], float search_pixel[2]){	float frame_pixel[2];	float search_origin_frame_pixel[2];	marker_unified_to_frame_pixel_coordinates(frame_width, frame_height, marker, marker_unified, frame_pixel);	tracking_get_search_origin_frame_pixel(frame_width, frame_height, marker, search_origin_frame_pixel);	sub_v2_v2v2(search_pixel, frame_pixel, search_origin_frame_pixel);}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:11,


示例8: stabilization_calculate_data

/* Calculate stabilization data (translation, scale and rotation) from * given median of first and current frame medians, tracking data and * frame number. * * NOTE: frame number should be in clip space, not scene space */static void stabilization_calculate_data(MovieTracking *tracking, int framenr, int width, int height,                                         const float firstmedian[2], const float median[2],                                         float translation[2], float *scale, float *angle){	MovieTrackingStabilization *stab = &tracking->stabilization;	*scale = (stab->scale - 1.0f) * stab->scaleinf + 1.0f;	*angle = 0.0f;	translation[0] = (firstmedian[0] - median[0]) * width * (*scale);	translation[1] = (firstmedian[1] - median[1]) * height * (*scale);	mul_v2_fl(translation, stab->locinf);	if ((stab->flag & TRACKING_STABILIZE_ROTATION) && stab->rot_track && stab->rotinf) {		MovieTrackingMarker *marker;		float a[2], b[2];		float x0 = (float)width / 2.0f, y0 = (float)height / 2.0f;		float x = median[0] * width, y = median[1] * height;		marker = BKE_tracking_marker_get(stab->rot_track, 1);		sub_v2_v2v2(a, marker->pos, firstmedian);		a[0] *= width;		a[1] *= height;		marker = BKE_tracking_marker_get(stab->rot_track, framenr);		sub_v2_v2v2(b, marker->pos, median);		b[0] *= width;		b[1] *= height;		*angle = -atan2f(a[0] * b[1] - a[1] * b[0], a[0] * b[0] + a[1] * b[1]);		*angle *= stab->rotinf;		/* convert to rotation around image center */		translation[0] -= (x0 + (x - x0) * cosf(*angle) - (y - y0) * sinf(*angle) - x) * (*scale);		translation[1] -= (y0 + (x - x0) * sinf(*angle) + (y - y0) * cosf(*angle) - y) * (*scale);	}}
开发者ID:dimilar,项目名称:blender-libmv,代码行数:44,


示例9: search_pixel_to_marker_unified

static void search_pixel_to_marker_unified(int frame_width, int frame_height,                                           const MovieTrackingMarker *marker,                                           const float search_pixel[2], float marker_unified[2]){	float frame_unified[2];	float search_origin_frame_pixel[2];	tracking_get_search_origin_frame_pixel(frame_width, frame_height, marker, search_origin_frame_pixel);	add_v2_v2v2(frame_unified, search_pixel, search_origin_frame_pixel);	pixel_to_unified(frame_width, frame_height, frame_unified, frame_unified);	/* marker pos is in frame unified */	sub_v2_v2v2(marker_unified, frame_unified, marker->pos);}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:14,


示例10: BLI_convexhull_aabb_fit_hull_2d

/** * /return The best angle for fitting the convex hull to an axis aligned bounding box. * * Intended to be used with #BLI_convexhull_2d * * /param points  Orded hull points * (result of #BLI_convexhull_2d mapped to a contiguous array). * * /note we could return the index of the best edge too if its needed. */float BLI_convexhull_aabb_fit_hull_2d(const float (*points_hull)[2], unsigned int n){	unsigned int i, i_prev;	float area_best = FLT_MAX;	float angle_best = 0.0f;	i_prev = n - 1;	for (i = 0; i < n; i++) {		const float *ev_a = points_hull[i];		const float *ev_b = points_hull[i_prev];		float dvec[2];		sub_v2_v2v2(dvec, ev_a, ev_b);		if (normalize_v2(dvec) != 0.0f) {			float mat[2][2];			float min[2] = {FLT_MAX, FLT_MAX}, max[2] = {-FLT_MAX, -FLT_MAX};			unsigned int j;			const float angle = atan2f(dvec[0], dvec[1]);			float area;			angle_to_mat2(mat, angle);			for (j = 0; j < n; j++) {				float tvec[2];				mul_v2_m2v2(tvec, mat, points_hull[j]);				min[0] = min_ff(min[0], tvec[0]);				min[1] = min_ff(min[1], tvec[1]);				max[0] = max_ff(max[0], tvec[0]);				max[1] = max_ff(max[1], tvec[1]);				area = (max[0] - min[0]) * (max[1] - min[1]);				if (area > area_best) {					break;				}			}			if (area < area_best) {				area_best = area;				angle_best = angle;			}		}		i_prev = i;	}	return angle_best;}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:60,


示例11: calc_ray_shift

static void calc_ray_shift(rcti *rect, float x, float y, const float source[2], float ray_length){	float co[2] = {(float)x, (float)y};	float dir[2], dist;	/* move (x,y) vector toward the source by ray_length distance */	sub_v2_v2v2(dir, co, source);	dist = normalize_v2(dir);	mul_v2_fl(dir, min_ff(dist, ray_length));	sub_v2_v2(co, dir);	int ico[2] = {(int)co[0], (int)co[1]};	BLI_rcti_do_minmax_v(rect, ico);}
开发者ID:floored,项目名称:blender,代码行数:14,


示例12: BLI_convexhull_aabb_fit_hull_2d

/** * /return The best angle for fitting the convex hull to an axis aligned bounding box. * * Intended to be used with #BLI_convexhull_2d * * /param points_hull  Ordered hull points * (result of #BLI_convexhull_2d mapped to a contiguous array). * * /note we could return the index of the best edge too if its needed. */float BLI_convexhull_aabb_fit_hull_2d(const float (*points_hull)[2], unsigned int n){	unsigned int i, i_prev;	float area_best = FLT_MAX;	float dvec_best[2];  /* best angle, delay atan2 */	i_prev = n - 1;	for (i = 0; i < n; i++) {		const float *ev_a = points_hull[i];		const float *ev_b = points_hull[i_prev];		float dvec[2];  /* 2d rotation matrix */		sub_v2_v2v2(dvec, ev_a, ev_b);		if (normalize_v2(dvec) != 0.0f) {			/* rotation matrix */			float min[2] = {FLT_MAX, FLT_MAX}, max[2] = {-FLT_MAX, -FLT_MAX};			unsigned int j;			float area;			for (j = 0; j < n; j++) {				float tvec[2];				mul_v2_v2_cw(tvec, dvec, points_hull[j]);				min[0] = min_ff(min[0], tvec[0]);				min[1] = min_ff(min[1], tvec[1]);				max[0] = max_ff(max[0], tvec[0]);				max[1] = max_ff(max[1], tvec[1]);				area = (max[0] - min[0]) * (max[1] - min[1]);				if (area > area_best) {					break;				}			}			if (area < area_best) {				area_best = area;				copy_v2_v2(dvec_best, dvec);			}		}		i_prev = i;	}	return (area_best != FLT_MAX) ? atan2f(dvec_best[0], dvec_best[1]) : 0.0f;}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:56,


示例13: mesh_bisect_interactive_calc

static bool mesh_bisect_interactive_calc(        bContext *C, wmOperator *op,        BMEditMesh *em,        float plane_co[3], float plane_no[3]){	wmGesture *gesture = op->customdata;	BisectData *opdata;	ARegion *ar = CTX_wm_region(C);	RegionView3D *rv3d = ar->regiondata;	int x_start = RNA_int_get(op->ptr, "xstart");	int y_start = RNA_int_get(op->ptr, "ystart");	int x_end = RNA_int_get(op->ptr, "xend");	int y_end = RNA_int_get(op->ptr, "yend");	/* reference location (some point in front of the view) for finding a point on a plane */	const float *co_ref = rv3d->ofs;	float co_a_ss[2] = {x_start, y_start}, co_b_ss[2] = {x_end, y_end}, co_delta_ss[2];	float co_a[3], co_b[3];	const float zfac = ED_view3d_calc_zfac(rv3d, co_ref, NULL);	opdata = gesture->userdata;	/* view vector */	ED_view3d_win_to_vector(ar, co_a_ss, co_a);	/* view delta */	sub_v2_v2v2(co_delta_ss, co_a_ss, co_b_ss);	ED_view3d_win_to_delta(ar, co_delta_ss, co_b, zfac);	/* cross both to get a normal */	cross_v3_v3v3(plane_no, co_a, co_b);	normalize_v3(plane_no);  /* not needed but nicer for user */	/* point on plane, can use either start or endpoint */	ED_view3d_win_to_3d(ar, co_ref, co_a_ss, plane_co);	if (opdata->is_first == false)		EDBM_redo_state_restore(opdata->mesh_backup, em, false);	opdata->is_first = false;	return true;}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:45,


示例14: getArrowEndPoint

static void getArrowEndPoint(const int width, const int height, const float zoom,                             const float start_corner[2], const float end_corner[2],                             float end_point[2]){	float direction[2];	float max_length;	sub_v2_v2v2(direction, end_corner, start_corner);	direction[0] *= width;	direction[1] *= height;	max_length = normalize_v2(direction);	mul_v2_fl(direction, min_ff(32.0f / zoom, max_length));	direction[0] /= width;	direction[1] /= height;	add_v2_v2v2(end_point, start_corner, direction);}
开发者ID:manwapastorelli,项目名称:blender-git,代码行数:18,


示例15: paintcurve_slide_modal

static int paintcurve_slide_modal(bContext *C, wmOperator *op, const wmEvent *event){	PointSlideData *psd = op->customdata;	if (event->type == psd->event && event->val == KM_RELEASE) {		MEM_freeN(psd);		ED_paintcurve_undo_push_begin(op->type->name);		ED_paintcurve_undo_push_end();		return OPERATOR_FINISHED;	}	switch (event->type) {		case MOUSEMOVE:		{			ARegion *ar = CTX_wm_region(C);			wmWindow *window = CTX_wm_window(C);			float diff[2] = {				event->mval[0] - psd->initial_loc[0],				event->mval[1] - psd->initial_loc[1]};			if (psd->select == 1) {				int i;				for (i = 0; i < 3; i++)					add_v2_v2v2(psd->pcp->bez.vec[i], diff, psd->point_initial_loc[i]);			}			else {				add_v2_v2(diff, psd->point_initial_loc[psd->select]);				copy_v2_v2(psd->pcp->bez.vec[psd->select], diff);				if (psd->align) {					char opposite = (psd->select == 0) ? 2 : 0;					sub_v2_v2v2(diff, psd->pcp->bez.vec[1], psd->pcp->bez.vec[psd->select]);					add_v2_v2v2(psd->pcp->bez.vec[opposite], psd->pcp->bez.vec[1], diff);				}			}			WM_paint_cursor_tag_redraw(window, ar);			break;		}		default:			break;	}	return OPERATOR_RUNNING_MODAL;}
开发者ID:wchargin,项目名称:blender,代码行数:43,


示例16: BLI_dial_angle

float BLI_dial_angle(Dial *dial, float current_position[2]){	float current_direction[2];		sub_v2_v2v2(current_direction, current_position, dial->center);	/* only update when we have enough precision, by having the mouse adequately away from center */	if (len_squared_v2(current_direction) > dial->threshold_squared) {		float angle;		float cosval, sinval;		normalize_v2(current_direction);		if (!dial->initialized) {			copy_v2_v2(dial->initial_direction, current_direction);			dial->initialized = true;		}				/* calculate mouse angle between initial and final mouse position */		cosval = dot_v2v2(current_direction, dial->initial_direction);		sinval = cross_v2v2(current_direction, dial->initial_direction);				/* clamp to avoid nans in acos */		angle = atan2f(sinval, cosval);				/* change of sign, we passed the 180 degree threshold. This means we need to add a turn.		 * to distinguish between transition from 0 to -1 and -PI to +PI, use comparison with PI/2 */		if ((angle * dial->last_angle < 0.0f) &&		    (fabsf(dial->last_angle) > (float)M_PI_2))		{			if (dial->last_angle < 0.0f)				dial->rotations--;			else				dial->rotations++;		}		dial->last_angle = angle;				return angle + 2.0f * (float)M_PI * dial->rotations;	}		return dial->last_angle;}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:42,


示例17: tracking_error_segment_point_cb

static void tracking_error_segment_point_cb(void *userdata,                                            MovieTrackingTrack *track, MovieTrackingMarker *marker,                                            int coord, int scene_framenr, float UNUSED(value)){	if (coord == 1) {		TrackErrorCurveUserData *data = (TrackErrorCurveUserData *) userdata;		float reprojected_position[4], bundle_position[4], marker_position[2], delta[2];		float reprojection_error;		float weight = BKE_tracking_track_get_weight_for_marker(data->clip, track, marker);		if (!data->matrix_initialized || data->matrix_frame != scene_framenr) {			BKE_tracking_get_projection_matrix(data->tracking, data->tracking_object,			                                   scene_framenr, data->width, data->height,			                                   data->projection_matrix);		}		copy_v3_v3(bundle_position, track->bundle_pos);		bundle_position[3] = 1;		mul_v4_m4v4(reprojected_position, data->projection_matrix, bundle_position);		reprojected_position[0] = (reprojected_position[0] /		                          (reprojected_position[3] * 2.0f) + 0.5f) * data->width;		reprojected_position[1] = (reprojected_position[1] /		                          (reprojected_position[3] * 2.0f) + 0.5f) * data->height * data->aspy;		BKE_tracking_distort_v2(data->tracking, reprojected_position, reprojected_position);		marker_position[0] = (marker->pos[0] + track->offset[0]) * data->width;		marker_position[1] = (marker->pos[1] + track->offset[1]) * data->height * data->aspy;		sub_v2_v2v2(delta, reprojected_position, marker_position);		reprojection_error = len_v2(delta) * weight;		glVertex2f(scene_framenr, reprojection_error);	}}
开发者ID:Walid-Shouman,项目名称:Blender,代码行数:36,


示例18: BLI_buffer_declare_static

UvVertMap *BKE_mesh_uv_vert_map_create(        struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv,        unsigned int totpoly, unsigned int totvert,        const float limit[2], const bool selected, const bool use_winding){	UvVertMap *vmap;	UvMapVert *buf;	MPoly *mp;	unsigned int a;	int i, totuv, nverts;	bool *winding = NULL;	BLI_buffer_declare_static(vec2f, tf_uv_buf, BLI_BUFFER_NOP, 32);	totuv = 0;	/* generate UvMapVert array */	mp = mpoly;	for (a = 0; a < totpoly; a++, mp++)		if (!selected || (!(mp->flag & ME_HIDE) && (mp->flag & ME_FACE_SEL)))			totuv += mp->totloop;	if (totuv == 0)		return NULL;	vmap = (UvVertMap *)MEM_callocN(sizeof(*vmap), "UvVertMap");	buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * (size_t)totuv, "UvMapVert");	vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totvert, "UvMapVert*");	if (use_winding) {		winding = MEM_callocN(sizeof(*winding) * totpoly, "winding");	}	if (!vmap->vert || !vmap->buf) {		BKE_mesh_uv_vert_map_free(vmap);		return NULL;	}	mp = mpoly;	for (a = 0; a < totpoly; a++, mp++) {		if (!selected || (!(mp->flag & ME_HIDE) && (mp->flag & ME_FACE_SEL))) {			float (*tf_uv)[2] = NULL;			if (use_winding) {				tf_uv = (float (*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, (size_t)mp->totloop);			}			nverts = mp->totloop;			for (i = 0; i < nverts; i++) {				buf->tfindex = (unsigned char)i;				buf->f = a;				buf->separate = 0;				buf->next = vmap->vert[mloop[mp->loopstart + i].v];				vmap->vert[mloop[mp->loopstart + i].v] = buf;				if (use_winding) {					copy_v2_v2(tf_uv[i], mloopuv[mpoly[a].loopstart + i].uv);				}				buf++;			}			if (use_winding) {				winding[a] = cross_poly_v2((const float (*)[2])tf_uv, (unsigned int)nverts) > 0;			}		}	}	/* sort individual uvs for each vert */	for (a = 0; a < totvert; a++) {		UvMapVert *newvlist = NULL, *vlist = vmap->vert[a];		UvMapVert *iterv, *v, *lastv, *next;		float *uv, *uv2, uvdiff[2];		while (vlist) {			v = vlist;			vlist = vlist->next;			v->next = newvlist;			newvlist = v;			uv = mloopuv[mpoly[v->f].loopstart + v->tfindex].uv;			lastv = NULL;			iterv = vlist;			while (iterv) {				next = iterv->next;				uv2 = mloopuv[mpoly[iterv->f].loopstart + iterv->tfindex].uv;				sub_v2_v2v2(uvdiff, uv2, uv);				if (fabsf(uv[0] - uv2[0]) < limit[0] && fabsf(uv[1] - uv2[1]) < limit[1] &&				    (!use_winding || winding[iterv->f] == winding[v->f]))				{					if (lastv) lastv->next = next;					else vlist = next;					iterv->next = newvlist;					newvlist = iterv;				}				else//.........这里部分代码省略.........
开发者ID:DrangPo,项目名称:blender,代码行数:101,


示例19: calchandle_curvemap

/* reduced copy of garbled calchandleNurb() code in curve.c */static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *next, int UNUSED(mode)){	float *p1, *p2, *p3, pt[3];	float len, len_a, len_b;	float dvec_a[2], dvec_b[2];	if (bezt->h1 == 0 && bezt->h2 == 0) {		return;	}		p2 = bezt->vec[1];		if (prev == NULL) {		p3 = next->vec[1];		pt[0] = 2.0f * p2[0] - p3[0];		pt[1] = 2.0f * p2[1] - p3[1];		p1 = pt;	}	else {		p1 = prev->vec[1];	}		if (next == NULL) {		p1 = prev->vec[1];		pt[0] = 2.0f * p2[0] - p1[0];		pt[1] = 2.0f * p2[1] - p1[1];		p3 = pt;	}	else {		p3 = next->vec[1];	}	sub_v2_v2v2(dvec_a, p2, p1);	sub_v2_v2v2(dvec_b, p3, p2);	len_a = len_v2(dvec_a);	len_b = len_v2(dvec_b);	if (len_a == 0.0f) len_a = 1.0f;	if (len_b == 0.0f) len_b = 1.0f;	if (bezt->h1 == HD_AUTO || bezt->h2 == HD_AUTO) { /* auto */		float tvec[2];		tvec[0] = dvec_b[0] / len_b + dvec_a[0] / len_a;		tvec[1] = dvec_b[1] / len_b + dvec_a[1] / len_a;		len = len_v2(tvec) * 2.5614f;		if (len != 0.0f) {						if (bezt->h1 == HD_AUTO) {				len_a /= len;				madd_v2_v2v2fl(p2 - 3, p2, tvec, -len_a);			}			if (bezt->h2 == HD_AUTO) {				len_b /= len;				madd_v2_v2v2fl(p2 + 3, p2, tvec,  len_b);			}		}	}	if (bezt->h1 == HD_VECT) {    /* vector */		madd_v2_v2v2fl(p2 - 3, p2, dvec_a, -1.0f / 3.0f);	}	if (bezt->h2 == HD_VECT) {		madd_v2_v2v2fl(p2 + 3, p2, dvec_b,  1.0f / 3.0f);	}}
开发者ID:nttputus,项目名称:blensor,代码行数:68,


示例20: slide_point_modal

static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event){	SlidePointData *data = (SlidePointData *)op->customdata;	BezTriple *bezt = &data->point->bezt;	float co[2], dco[2];	switch (event->type) {		case LEFTALTKEY:		case RIGHTALTKEY:		case LEFTSHIFTKEY:		case RIGHTSHIFTKEY:			if (ELEM(event->type, LEFTALTKEY, RIGHTALTKEY)) {				if (data->action == SLIDE_ACTION_FEATHER)					data->overall_feather = (event->val == KM_PRESS);				else					data->curvature_only = (event->val == KM_PRESS);			}			if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY))				data->accurate = (event->val == KM_PRESS);			/* fall-through */  /* update CV position */		case MOUSEMOVE:		{			ScrArea *sa = CTX_wm_area(C);			ARegion *ar = CTX_wm_region(C);			ED_mask_mouse_pos(sa, ar, event->mval, co);			sub_v2_v2v2(dco, co, data->co);			if (data->action == SLIDE_ACTION_HANDLE) {				float delta[2], offco[2];				sub_v2_v2v2(delta, data->handle, data->co);				sub_v2_v2v2(offco, co, data->co);				if (data->accurate)					mul_v2_fl(offco, 0.2f);				add_v2_v2(offco, data->co);				add_v2_v2(offco, delta);				BKE_mask_point_set_handle(data->point, offco, data->curvature_only, data->handle, data->vec);			}			else if (data->action == SLIDE_ACTION_POINT) {				float delta[2];				copy_v2_v2(delta, dco);				if (data->accurate)					mul_v2_fl(delta, 0.2f);				add_v2_v2v2(bezt->vec[0], data->vec[0], delta);				add_v2_v2v2(bezt->vec[1], data->vec[1], delta);				add_v2_v2v2(bezt->vec[2], data->vec[2], delta);			}			else if (data->action == SLIDE_ACTION_FEATHER) {				float vec[2], no[2], p[2], c[2], w, offco[2];				float *weight = NULL;				float weight_scalar = 1.0f;				int overall_feather = data->overall_feather || data->initial_feather;				add_v2_v2v2(offco, data->feather, dco);				if (data->uw) {					/* project on both sides and find the closest one,					 * prevents flickering when projecting onto both sides can happen */					const float u_pos = BKE_mask_spline_project_co(data->spline, data->point,					                                               data->uw->u, offco, MASK_PROJ_NEG);					const float u_neg = BKE_mask_spline_project_co(data->spline, data->point,					                                               data->uw->u, offco, MASK_PROJ_POS);					float dist_pos = FLT_MAX;					float dist_neg = FLT_MAX;					float co_pos[2];					float co_neg[2];					float u;					if (u_pos > 0.0f && u_pos < 1.0f) {						BKE_mask_point_segment_co(data->spline, data->point, u_pos, co_pos);						dist_pos = len_squared_v2v2(offco, co_pos);					}					if (u_neg > 0.0f && u_neg < 1.0f) {						BKE_mask_point_segment_co(data->spline, data->point, u_neg, co_neg);						dist_neg = len_squared_v2v2(offco, co_neg);					}					u = dist_pos < dist_neg ? u_pos : u_neg;					if (u > 0.0f && u < 1.0f) {						data->uw->u = u;						data->uw = BKE_mask_point_sort_uw(data->point, data->uw);						weight = &data->uw->w;						weight_scalar = BKE_mask_point_weight_scalar(data->spline, data->point, u);						if (weight_scalar != 0.0f) {							weight_scalar = 1.0f / weight_scalar;						}						BKE_mask_point_normal(data->spline, data->point, data->uw->u, no);						BKE_mask_point_segment_co(data->spline, data->point, data->uw->u, p);					}//.........这里部分代码省略.........
开发者ID:castlelore,项目名称:blender-git,代码行数:101,


示例21: ED_mask_find_nearest_diff_point

bool ED_mask_find_nearest_diff_point(const bContext *C,                                     struct Mask *mask,                                     const float normal_co[2],                                     int threshold, bool feather,                                     MaskLayer **masklay_r,                                     MaskSpline **spline_r,                                     MaskSplinePoint **point_r,                                     float *u_r, float tangent[2],                                     const bool use_deform,                                     const bool use_project){	ScrArea *sa = CTX_wm_area(C);	ARegion *ar = CTX_wm_region(C);	MaskLayer *masklay, *point_masklay;	MaskSpline *point_spline;	MaskSplinePoint *point = NULL;	float dist = FLT_MAX, co[2];	int width, height;	float u;	float scalex, scaley;	ED_mask_get_size(sa, &width, &height);	ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley);	co[0] = normal_co[0] * scalex;	co[1] = normal_co[1] * scaley;	for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {		MaskSpline *spline;		if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {			continue;		}		for (spline = masklay->splines.first; spline; spline = spline->next) {			int i;			MaskSplinePoint *cur_point;			for (i = 0, cur_point = use_deform ? spline->points_deform : spline->points;			     i < spline->tot_point;			     i++, cur_point++)			{				float *diff_points;				unsigned int tot_diff_point;				diff_points = BKE_mask_point_segment_diff(spline, cur_point, width, height,				                                          &tot_diff_point);				if (diff_points) {					int j, tot_point;					unsigned int tot_feather_point;					float *feather_points = NULL, *points;					if (feather) {						feather_points = BKE_mask_point_segment_feather_diff(spline, cur_point,						                                                     width, height,						                                                     &tot_feather_point);						points = feather_points;						tot_point = tot_feather_point;					}					else {						points = diff_points;						tot_point = tot_diff_point;					}					for (j = 0; j < tot_point - 1; j++) {						float cur_dist, a[2], b[2];						a[0] = points[2 * j] * scalex;						a[1] = points[2 * j + 1] * scaley;						b[0] = points[2 * j + 2] * scalex;						b[1] = points[2 * j + 3] * scaley;						cur_dist = dist_to_line_segment_v2(co, a, b);						if (cur_dist < dist) {							if (tangent)								sub_v2_v2v2(tangent, &diff_points[2 * j + 2], &diff_points[2 * j]);							point_masklay = masklay;							point_spline = spline;							point = use_deform ? &spline->points[(cur_point - spline->points_deform)] : cur_point;							dist = cur_dist;							u = (float)j / tot_point;						}					}					if (feather_points)						MEM_freeN(feather_points);					MEM_freeN(diff_points);				}			}		}	}	if (point && dist < threshold) {//.........这里部分代码省略.........
开发者ID:Walid-Shouman,项目名称:Blender,代码行数:101,


示例22: ruler_info_draw_pixel

//.........这里部分代码省略.........			/* text */			{				char numstr[256];				float numstr_size[2];				float pos[2];				const int prec = 2;  /* XXX, todo, make optional */				ruler_item_as_string(ruler_item, unit, numstr, sizeof(numstr), prec);				BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]);				pos[0] = co_ss[1][0] + (cap_size * 2.0f);				pos[1] = co_ss[1][1] - (numstr_size[1] / 2.0f);				/* draw text (bg) */				glColor4ubv(color_back);				uiSetRoundBox(UI_CNR_ALL);				uiRoundBox(pos[0] - bg_margin,                  pos[1] - bg_margin,				           pos[0] + bg_margin + numstr_size[0], pos[1] + bg_margin + numstr_size[1],				           bg_radius);				/* draw text */				glColor3ubv(color_text);				BLF_position(blf_mono_font, pos[0], pos[1], 0.0f);				BLF_rotation(blf_mono_font, 0.0f);				BLF_draw(blf_mono_font, numstr, sizeof(numstr));			}			/* capping */			{				float rot_90_vec_a[2];				float rot_90_vec_b[2];				float cap[2];				sub_v2_v2v2(dir_ruler, co_ss[0], co_ss[1]);				rot_90_vec_a[0] = -dir_ruler[1];				rot_90_vec_a[1] =  dir_ruler[0];				normalize_v2(rot_90_vec_a);				sub_v2_v2v2(dir_ruler, co_ss[1], co_ss[2]);				rot_90_vec_b[0] = -dir_ruler[1];				rot_90_vec_b[1] =  dir_ruler[0];				normalize_v2(rot_90_vec_b);				glEnable(GL_BLEND);				glColor3ubv(color_wire);				glBegin(GL_LINES);				madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, cap_size);				glVertex2fv(cap);				madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, -cap_size);				glVertex2fv(cap);				madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec_b, cap_size);				glVertex2fv(cap);				madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec_b, -cap_size);				glVertex2fv(cap);				/* angle vertex */				glVertex2f(co_ss[1][0] - cap_size, co_ss[1][1] - cap_size);				glVertex2f(co_ss[1][0] + cap_size, co_ss[1][1] + cap_size);				glVertex2f(co_ss[1][0] - cap_size, co_ss[1][1] + cap_size);				glVertex2f(co_ss[1][0] + cap_size, co_ss[1][1] - cap_size);				glEnd();
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:66,


示例23: setNearestAxis3d

static void setNearestAxis3d(TransInfo *t){	float zfac;	float mvec[3], proj[3];	float len[3];	int i;	/* calculate mouse movement */	mvec[0] = (float)(t->mval[0] - t->con.imval[0]);	mvec[1] = (float)(t->mval[1] - t->con.imval[1]);	mvec[2] = 0.0f;	/* we need to correct axis length for the current zoomlevel of view,	 * this to prevent projected values to be clipped behind the camera	 * and to overflow the short integers.	 * The formula used is a bit stupid, just a simplification of the subtraction	 * of two 2D points 30 pixels apart (that's the last factor in the formula) after	 * projecting them with ED_view3d_win_to_delta and then get the length of that vector.	 */	zfac = mul_project_m4_v3_zfac(t->persmat, t->center);	zfac = len_v3(t->persinv[0]) * 2.0f / t->ar->winx * zfac * 30.0f;	for (i = 0; i < 3; i++) {		float axis[3], axis_2d[2];		copy_v3_v3(axis, t->con.mtx[i]);		mul_v3_fl(axis, zfac);		/* now we can project to get window coordinate */		add_v3_v3(axis, t->center_global);		projectFloatView(t, axis, axis_2d);		sub_v2_v2v2(axis, axis_2d, t->center2d);		axis[2] = 0.0f;		if (normalize_v3(axis) > 1e-3f) {			project_v3_v3v3(proj, mvec, axis);			sub_v3_v3v3(axis, mvec, proj);			len[i] = normalize_v3(axis);		}		else {			len[i] = 1e10f;		}	}	if (len[0] <= len[1] && len[0] <= len[2]) {		if (t->modifiers & MOD_CONSTRAINT_PLANE) {			t->con.mode |= (CON_AXIS1 | CON_AXIS2);			BLI_snprintf(t->con.text, sizeof(t->con.text), IFACE_(" locking %s X axis"), t->spacename);		}		else {			t->con.mode |= CON_AXIS0;			BLI_snprintf(t->con.text, sizeof(t->con.text), IFACE_(" along %s X axis"), t->spacename);		}	}	else if (len[1] <= len[0] && len[1] <= len[2]) {		if (t->modifiers & MOD_CONSTRAINT_PLANE) {			t->con.mode |= (CON_AXIS0 | CON_AXIS2);			BLI_snprintf(t->con.text, sizeof(t->con.text), IFACE_(" locking %s Y axis"), t->spacename);		}		else {			t->con.mode |= CON_AXIS1;			BLI_snprintf(t->con.text, sizeof(t->con.text), IFACE_(" along %s Y axis"), t->spacename);		}	}	else if (len[2] <= len[1] && len[2] <= len[0]) {		if (t->modifiers & MOD_CONSTRAINT_PLANE) {			t->con.mode |= (CON_AXIS0 | CON_AXIS1);			BLI_snprintf(t->con.text, sizeof(t->con.text), IFACE_(" locking %s Z axis"), t->spacename);		}		else {			t->con.mode |= CON_AXIS2;			BLI_snprintf(t->con.text, sizeof(t->con.text), IFACE_(" along %s Z axis"), t->spacename);		}	}}
开发者ID:GeniaPenksik,项目名称:blender,代码行数:76,


示例24: draw_marker_areas

static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,                              const float marker_pos[2], int width, int height, int act, int sel){	int tiny = sc->flag & SC_SHOW_TINY_MARKER;	bool show_search = false;	float col[3], scol[3], px[2];	track_colors(track, act, col, scol);	px[0] = 1.0f / width / sc->zoom;	px[1] = 1.0f / height / sc->zoom;	/* marker position and offset position */	if ((track->flag & SELECT) == sel && (marker->flag & MARKER_DISABLED) == 0) {		float pos[2], p[2];		if (track->flag & TRACK_LOCKED) {			if (act)				UI_ThemeColor(TH_ACT_MARKER);			else if (track->flag & SELECT)				UI_ThemeColorShade(TH_LOCK_MARKER, 64);			else				UI_ThemeColor(TH_LOCK_MARKER);		}		else {			if (track->flag & SELECT)				glColor3fv(scol);			else				glColor3fv(col);		}		add_v2_v2v2(pos, marker->pos, track->offset);		ED_clip_point_undistorted_pos(sc, pos, pos);		sub_v2_v2v2(p, pos, marker_pos);		if (isect_point_quad_v2(p, marker->pattern_corners[0], marker->pattern_corners[1],		                        marker->pattern_corners[2], marker->pattern_corners[3]))		{			if (!tiny)				glPointSize(2.0f);			glBegin(GL_POINTS);			glVertex2f(pos[0], pos[1]);			glEnd();			if (!tiny)				glPointSize(1.0f);		}		else {			glBegin(GL_LINES);			glVertex2f(pos[0] + px[0] * 3, pos[1]);			glVertex2f(pos[0] + px[0] * 7, pos[1]);			glVertex2f(pos[0] - px[0] * 3, pos[1]);			glVertex2f(pos[0] - px[0] * 7, pos[1]);			glVertex2f(pos[0], pos[1] - px[1] * 3);			glVertex2f(pos[0], pos[1] - px[1] * 7);			glVertex2f(pos[0], pos[1] + px[1] * 3);			glVertex2f(pos[0], pos[1] + px[1] * 7);			glEnd();			glColor3f(0.0f, 0.0f, 0.0f);			glLineStipple(3, 0xaaaa);			glEnable(GL_LINE_STIPPLE);			glEnable(GL_COLOR_LOGIC_OP);			glLogicOp(GL_NOR);			glBegin(GL_LINES);			glVertex2fv(pos);			glVertex2fv(marker_pos);			glEnd();			glDisable(GL_COLOR_LOGIC_OP);			glDisable(GL_LINE_STIPPLE);		}	}	/* pattern */	glPushMatrix();	glTranslatef(marker_pos[0], marker_pos[1], 0);	if (tiny) {		glLineStipple(3, 0xaaaa);		glEnable(GL_LINE_STIPPLE);	}	if ((track->pat_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_PATTERN)) {		if (track->flag & TRACK_LOCKED) {			if (act)				UI_ThemeColor(TH_ACT_MARKER);			else if (track->pat_flag & SELECT)				UI_ThemeColorShade(TH_LOCK_MARKER, 64);			else UI_ThemeColor(TH_LOCK_MARKER);		}		else if (marker->flag & MARKER_DISABLED) {			if (act)				UI_ThemeColor(TH_ACT_MARKER);//.........这里部分代码省略.........
开发者ID:manwapastorelli,项目名称:blender-git,代码行数:101,


示例25: draw_marker_outline

static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,                                const float marker_pos[2], int width, int height){	int tiny = sc->flag & SC_SHOW_TINY_MARKER;	bool show_search = false;	float px[2];	UI_ThemeColor(TH_MARKER_OUTLINE);	px[0] = 1.0f / width / sc->zoom;	px[1] = 1.0f / height / sc->zoom;	if ((marker->flag & MARKER_DISABLED) == 0) {		float pos[2];		float p[2];		add_v2_v2v2(pos, marker->pos, track->offset);		ED_clip_point_undistorted_pos(sc, pos, pos);		sub_v2_v2v2(p, pos, marker_pos);		if (isect_point_quad_v2(p, marker->pattern_corners[0], marker->pattern_corners[1],		                        marker->pattern_corners[2], marker->pattern_corners[3]))		{			if (tiny) glPointSize(3.0f);			else glPointSize(4.0f);			glBegin(GL_POINTS);			glVertex2f(pos[0], pos[1]);			glEnd();			glPointSize(1.0f);		}		else {			if (!tiny) glLineWidth(3.0f);			glBegin(GL_LINES);			glVertex2f(pos[0] + px[0] * 2, pos[1]);			glVertex2f(pos[0] + px[0] * 8, pos[1]);			glVertex2f(pos[0] - px[0] * 2, pos[1]);			glVertex2f(pos[0] - px[0] * 8, pos[1]);			glVertex2f(pos[0], pos[1] - px[1] * 2);			glVertex2f(pos[0], pos[1] - px[1] * 8);			glVertex2f(pos[0], pos[1] + px[1] * 2);			glVertex2f(pos[0], pos[1] + px[1] * 8);			glEnd();			if (!tiny) glLineWidth(1.0f);		}	}	/* pattern and search outline */	glPushMatrix();	glTranslatef(marker_pos[0], marker_pos[1], 0);	if (!tiny)		glLineWidth(3.0f);	if (sc->flag & SC_SHOW_MARKER_PATTERN) {		glBegin(GL_LINE_LOOP);		glVertex2fv(marker->pattern_corners[0]);		glVertex2fv(marker->pattern_corners[1]);		glVertex2fv(marker->pattern_corners[2]);		glVertex2fv(marker->pattern_corners[3]);		glEnd();	}	show_search = (TRACK_VIEW_SELECTED(sc, track) &&	               ((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) != 0;	if (sc->flag & SC_SHOW_MARKER_SEARCH && show_search) {		glBegin(GL_LINE_LOOP);		glVertex2f(marker->search_min[0], marker->search_min[1]);		glVertex2f(marker->search_max[0], marker->search_min[1]);		glVertex2f(marker->search_max[0], marker->search_max[1]);		glVertex2f(marker->search_min[0], marker->search_max[1]);		glEnd();	}	glPopMatrix();	if (!tiny)		glLineWidth(1.0f);}
开发者ID:manwapastorelli,项目名称:blender-git,代码行数:82,


示例26: draw_distortion

//.........这里部分代码省略.........			for (i = 0; i <= n; i++) {				glVertex2fv(grid[i][j]);			}			glEnd();		}	}	if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {		MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking);		if (track) {			int framenr = ED_space_clip_get_clip_frame_number(sc);			MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);			offsx = marker->pos[0];			offsy = marker->pos[1];			gpd = track->gpd;		}	}	else {		gpd = clip->gpd;	}	if (sc->flag & SC_MANUAL_CALIBRATION && gpd) {		bGPDlayer *layer = gpd->layers.first;		while (layer) {			bGPDframe *frame = layer->frames.first;			if (layer->flag & GP_LAYER_HIDE) {				layer = layer->next;				continue;			}			glColor4fv(layer->color);			glLineWidth(layer->thickness);			glPointSize((float)(layer->thickness + 2));			while (frame) {				bGPDstroke *stroke = frame->strokes.first;				while (stroke) {					if (stroke->flag & GP_STROKE_2DSPACE) {						if (stroke->totpoints > 1) {							glBegin(GL_LINE_STRIP);							for (i = 0; i < stroke->totpoints - 1; i++) {								float npos[2], dpos[2], len;								int steps;								pos[0] = (stroke->points[i].x + offsx) * width;								pos[1] = (stroke->points[i].y + offsy) * height * aspy;								npos[0] = (stroke->points[i + 1].x + offsx) * width;								npos[1] = (stroke->points[i + 1].y + offsy) * height * aspy;								len = len_v2v2(pos, npos);								steps = ceil(len / 5.0f);								/* we want to distort only long straight lines */								if (stroke->totpoints == 2) {									BKE_tracking_undistort_v2(tracking, pos, pos);									BKE_tracking_undistort_v2(tracking, npos, npos);								}								sub_v2_v2v2(dpos, npos, pos);								mul_v2_fl(dpos, 1.0f / steps);								for (j = 0; j <= steps; j++) {									BKE_tracking_distort_v2(tracking, pos, tpos);									glVertex2f(tpos[0] / width, tpos[1] / (height * aspy));									add_v2_v2(pos, dpos);								}							}							glEnd();						}						else if (stroke->totpoints == 1) {							glBegin(GL_POINTS);							glVertex2f(stroke->points[0].x + offsx, stroke->points[0].y + offsy);							glEnd();						}					}					stroke = stroke->next;				}				frame = frame->next;			}			layer = layer->next;		}		glLineWidth(1.0f);		glPointSize(1.0f);	}	glPopMatrix();}
开发者ID:manwapastorelli,项目名称:blender-git,代码行数:101,



注:本文中的sub_v2_v2v2函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ sub_v3_v3函数代码示例
C++ subString函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。