Blender  V3.3
Classes | Macros | Functions
math_geom.c File Reference
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_math_bits.h"
#include "BLI_utildefines.h"
#include "BLI_strict_flags.h"

Go to the source code of this file.

Classes

struct  Float3_Len
 
struct  Double2_Len
 

Macros

#define CCW(A, B, C)   ((C[1] - A[1]) * (B[0] - A[0]) > (B[1] - A[1]) * (C[0] - A[0]))
 
#define MEAN_VALUE_HALF_TAN_V2(_area, i1, i2)
 
#define IS_ZERO(x)   ((x > (-DBL_EPSILON) && x < DBL_EPSILON) ? 1 : 0)
 
#define CROSS_SIGN(dir_a, dir_b)    ((void)cross_v3_v3v3(test_dir, dir_a, dir_b), (dot_v3v3(plane, test_dir) > 0.0f))
 

Functions

void cross_tri_v3 (float n[3], const float v1[3], const float v2[3], const float v3[3])
 
float normal_tri_v3 (float n[3], const float v1[3], const float v2[3], const float v3[3])
 
float normal_quad_v3 (float n[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
 
float normal_poly_v3 (float n[3], const float verts[][3], unsigned int nr)
 
float area_quad_v3 (const float v1[3], const float v2[3], const float v3[3], const float v4[3])
 
float area_squared_quad_v3 (const float v1[3], const float v2[3], const float v3[3], const float v4[3])
 
float area_tri_v3 (const float v1[3], const float v2[3], const float v3[3])
 
float area_squared_tri_v3 (const float v1[3], const float v2[3], const float v3[3])
 
float area_tri_signed_v3 (const float v1[3], const float v2[3], const float v3[3], const float normal[3])
 
float area_poly_v3 (const float verts[][3], unsigned int nr)
 
float area_squared_poly_v3 (const float verts[][3], unsigned int nr)
 
float cross_poly_v2 (const float verts[][2], unsigned int nr)
 
void cross_poly_v3 (float n[3], const float verts[][3], unsigned int nr)
 
float area_poly_v2 (const float verts[][2], unsigned int nr)
 
float area_poly_signed_v2 (const float verts[][2], unsigned int nr)
 
float area_squared_poly_v2 (const float verts[][2], unsigned int nr)
 
float cotangent_tri_weight_v3 (const float v1[3], const float v2[3], const float v3[3])
 
void plane_from_point_normal_v3 (float r_plane[4], const float plane_co[3], const float plane_no[3])
 
void plane_to_point_vector_v3 (const float plane[4], float r_plane_co[3], float r_plane_no[3])
 
void plane_to_point_vector_v3_normalized (const float plane[4], float r_plane_co[3], float r_plane_no[3])
 
float volume_tetrahedron_v3 (const float v1[3], const float v2[3], const float v3[3], const float v4[3])
 
float volume_tetrahedron_signed_v3 (const float v1[3], const float v2[3], const float v3[3], const float v4[3])
 
float volume_tri_tetrahedron_signed_v3_6x (const float v1[3], const float v2[3], const float v3[3])
 
float volume_tri_tetrahedron_signed_v3 (const float v1[3], const float v2[3], const float v3[3])
 
float dist_squared_to_line_v2 (const float p[2], const float l1[2], const float l2[2])
 
float dist_to_line_v2 (const float p[2], const float l1[2], const float l2[2])
 
float dist_squared_to_line_segment_v2 (const float p[2], const float l1[2], const float l2[2])
 
float dist_to_line_segment_v2 (const float p[2], const float l1[2], const float l2[2])
 
float closest_seg_seg_v2 (float r_closest_a[2], float r_closest_b[2], float *r_lambda_a, float *r_lambda_b, const float a1[2], const float a2[2], const float b1[2], const float b2[2])
 
float closest_to_line_segment_v2 (float r_close[2], const float p[2], const float l1[2], const float l2[2])
 
float closest_to_line_segment_v3 (float r_close[3], const float p[3], const float l1[3], const float l2[3])
 
void closest_to_plane_v3 (float r_close[3], const float plane[4], const float pt[3])
 
void closest_to_plane_normalized_v3 (float r_close[3], const float plane[4], const float pt[3])
 
void closest_to_plane3_v3 (float r_close[3], const float plane[3], const float pt[3])
 
void closest_to_plane3_normalized_v3 (float r_close[3], const float plane[3], const float pt[3])
 
float dist_signed_squared_to_plane_v3 (const float pt[3], const float plane[4])
 
float dist_squared_to_plane_v3 (const float pt[3], const float plane[4])
 
float dist_signed_squared_to_plane3_v3 (const float pt[3], const float plane[3])
 
float dist_squared_to_plane3_v3 (const float pt[3], const float plane[3])
 
float dist_signed_to_plane_v3 (const float pt[3], const float plane[4])
 
float dist_to_plane_v3 (const float pt[3], const float plane[4])
 
float dist_signed_to_plane3_v3 (const float pt[3], const float plane[3])
 
float dist_to_plane3_v3 (const float pt[3], const float plane[3])
 
float dist_squared_to_line_segment_v3 (const float p[3], const float l1[3], const float l2[3])
 
float dist_to_line_segment_v3 (const float p[3], const float l1[3], const float l2[3])
 
float dist_squared_to_line_v3 (const float p[3], const float l1[3], const float l2[3])
 
float dist_to_line_v3 (const float p[3], const float l1[3], const float l2[3])
 
float dist_signed_squared_to_corner_v3v3v3 (const float p[3], const float v1[3], const float v2[3], const float v3[3], const float axis_ref[3])
 
float dist_squared_to_ray_v3_normalized (const float ray_origin[3], const float ray_direction[3], const float co[3])
 
float dist_squared_ray_to_seg_v3 (const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], float r_point[3], float *r_depth)
 
void aabb_get_near_far_from_plane (const float plane_no[3], const float bbmin[3], const float bbmax[3], float bb_near[3], float bb_afar[3])
 
float dist_seg_seg_v2 (const float a1[3], const float a2[3], const float b1[3], const float b2[3])
 
void closest_on_tri_to_point_v3 (float r[3], const float p[3], const float v1[3], const float v2[3], const float v3[3])
 
int isect_seg_seg_v2_int (const int v1[2], const int v2[2], const int v3[2], const int v4[2])
 
int isect_line_line_v2_point (const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2])
 
int isect_seg_seg_v2 (const float v1[2], const float v2[2], const float v3[2], const float v4[2])
 
void isect_seg_seg_v3 (const float a0[3], const float a1[3], const float b0[3], const float b1[3], float r_a[3], float r_b[3])
 
int isect_seg_seg_v2_point_ex (const float v0[2], const float v1[2], const float v2[2], const float v3[2], const float endpoint_bias, float r_vi[2])
 
int isect_seg_seg_v2_point (const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2])
 
bool isect_seg_seg_v2_simple (const float v1[2], const float v2[2], const float v3[2], const float v4[2])
 
int isect_seg_seg_v2_lambda_mu_db (const double v1[2], const double v2[2], const double v3[2], const double v4[2], double *r_lambda, double *r_mu)
 
int isect_line_sphere_v3 (const float l1[3], const float l2[3], const float sp[3], const float r, float r_p1[3], float r_p2[3])
 
int isect_line_sphere_v2 (const float l1[2], const float l2[2], const float sp[2], const float r, float r_p1[2], float r_p2[2])
 
bool isect_point_poly_v2 (const float pt[2], const float verts[][2], const unsigned int nr, const bool UNUSED(use_holes))
 
bool isect_point_poly_v2_int (const int pt[2], const int verts[][2], const unsigned int nr, const bool UNUSED(use_holes))
 
bool isect_point_tri_v2_cw (const float pt[2], const float v1[2], const float v2[2], const float v3[2])
 
int isect_point_tri_v2 (const float pt[2], const float v1[2], const float v2[2], const float v3[2])
 
int isect_point_quad_v2 (const float pt[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2])
 
bool isect_line_segment_tri_v3 (const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
 
bool isect_line_segment_tri_epsilon_v3 (const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], const float epsilon)
 
bool isect_ray_tri_v3 (const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
 
bool isect_ray_plane_v3 (const float ray_origin[3], const float ray_direction[3], const float plane[4], float *r_lambda, const bool clip)
 
bool isect_ray_tri_epsilon_v3 (const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], const float epsilon)
 
void isect_ray_tri_watertight_v3_precalc (struct IsectRayPrecalc *isect_precalc, const float ray_direction[3])
 
bool isect_ray_tri_watertight_v3 (const float ray_origin[3], const struct IsectRayPrecalc *isect_precalc, const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
 
bool isect_ray_tri_watertight_v3_simple (const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
 
bool isect_ray_seg_v2 (const float ray_origin[2], const float ray_direction[2], const float v0[2], const float v1[2], float *r_lambda, float *r_u)
 
bool isect_ray_line_v3 (const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], float *r_lambda)
 
bool isect_point_planes_v3 (float(*planes)[4], int totplane, const float p[3])
 
bool isect_point_planes_v3_negated (const float(*planes)[4], const int totplane, const float p[3])
 
bool isect_line_plane_v3 (float r_isect_co[3], const float l1[3], const float l2[3], const float plane_co[3], const float plane_no[3])
 
bool isect_plane_plane_plane_v3 (const float plane_a[4], const float plane_b[4], const float plane_c[4], float r_isect_co[3])
 
bool isect_plane_plane_v3 (const float plane_a[4], const float plane_b[4], float r_isect_co[3], float r_isect_no[3])
 
bool isect_planes_v3_fn (const float planes[][4], const int planes_len, const float eps_coplanar, const float eps_isect, void(*callback_fn)(const float co[3], int i, int j, int k, void *user_data), void *user_data)
 
bool isect_tri_tri_v3_ex (const float tri_a[3][3], const float tri_b[3][3], float r_i1[3], float r_i2[3], int *r_tri_a_edge_isect_count)
 
bool isect_tri_tri_v3 (const float t_a0[3], const float t_a1[3], const float t_a2[3], const float t_b0[3], const float t_b1[3], const float t_b2[3], float r_i1[3], float r_i2[3])
 
static bool getLowestRoot (const float a, const float b, const float c, const float maxR, float *root)
 
int isect_aabb_planes_v3 (const float(*planes)[4], const int totplane, const float bbmin[3], const float bbmax[3])
 
bool isect_sweeping_sphere_tri_v3 (const float p1[3], const float p2[3], const float radius, const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float ipoint[3])
 
bool isect_axial_line_segment_tri_v3 (const int axis, const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda)
 
int isect_line_line_epsilon_v3 (const float v1[3], const float v2[3], const float v3[3], const float v4[3], float r_i1[3], float r_i2[3], const float epsilon)
 
int isect_line_line_v3 (const float v1[3], const float v2[3], const float v3[3], const float v4[3], float r_i1[3], float r_i2[3])
 
bool isect_line_line_strict_v3 (const float v1[3], const float v2[3], const float v3[3], const float v4[3], float vi[3], float *r_lambda)
 
bool isect_ray_ray_epsilon_v3 (const float ray_origin_a[3], const float ray_direction_a[3], const float ray_origin_b[3], const float ray_direction_b[3], const float epsilon, float *r_lambda_a, float *r_lambda_b)
 
bool isect_ray_ray_v3 (const float ray_origin_a[3], const float ray_direction_a[3], const float ray_origin_b[3], const float ray_direction_b[3], float *r_lambda_a, float *r_lambda_b)
 
bool isect_aabb_aabb_v3 (const float min1[3], const float max1[3], const float min2[3], const float max2[3])
 
void isect_ray_aabb_v3_precalc (struct IsectRayAABB_Precalc *data, const float ray_origin[3], const float ray_direction[3])
 
bool isect_ray_aabb_v3 (const struct IsectRayAABB_Precalc *data, const float bb_min[3], const float bb_max[3], float *tmin_out)
 
bool isect_ray_aabb_v3_simple (const float orig[3], const float dir[3], const float bb_min[3], const float bb_max[3], float *tmin, float *tmax)
 
float closest_to_ray_v3 (float r_close[3], const float p[3], const float ray_orig[3], const float ray_dir[3])
 
float closest_to_line_v3 (float r_close[3], const float p[3], const float l1[3], const float l2[3])
 
float closest_to_line_v2 (float r_close[2], const float p[2], const float l1[2], const float l2[2])
 
double closest_to_line_v2_db (double r_close[2], const double p[2], const double l1[2], const double l2[2])
 
float ray_point_factor_v3_ex (const float p[3], const float ray_origin[3], const float ray_direction[3], const float epsilon, const float fallback)
 
float ray_point_factor_v3 (const float p[3], const float ray_origin[3], const float ray_direction[3])
 
float line_point_factor_v3_ex (const float p[3], const float l1[3], const float l2[3], const float epsilon, const float fallback)
 
float line_point_factor_v3 (const float p[3], const float l1[3], const float l2[3])
 
float line_point_factor_v2_ex (const float p[2], const float l1[2], const float l2[2], const float epsilon, const float fallback)
 
float line_point_factor_v2 (const float p[2], const float l1[2], const float l2[2])
 
float line_plane_factor_v3 (const float plane_co[3], const float plane_no[3], const float l1[3], const float l2[3])
 
void limit_dist_v3 (float v1[3], float v2[3], const float dist)
 
int isect_point_tri_v2_int (const int x1, const int y1, const int x2, const int y2, const int a, const int b)
 
static bool point_in_slice (const float p[3], const float v1[3], const float l1[3], const float l2[3])
 
static bool point_in_slice_as (const float p[3], const float origin[3], const float normal[3])
 
bool point_in_slice_seg (float p[3], float l1[3], float l2[3])
 
bool isect_point_tri_prism_v3 (const float p[3], const float v1[3], const float v2[3], const float v3[3])
 
bool isect_point_tri_v3 (const float p[3], const float v1[3], const float v2[3], const float v3[3], float r_isect_co[3])
 
bool clip_segment_v3_plane (const float p1[3], const float p2[3], const float plane[4], float r_p1[3], float r_p2[3])
 
bool clip_segment_v3_plane_n (const float p1[3], const float p2[3], const float plane_array[][4], const int plane_num, float r_p1[3], float r_p2[3])
 
void axis_dominant_v3_to_m3 (float r_mat[3][3], const float normal[3])
 Normal to x,y matrix. More...
 
void axis_dominant_v3_to_m3_negate (float r_mat[3][3], const float normal[3])
 
static float tri_signed_area (const float v1[3], const float v2[3], const float v3[3], const int i, const int j)
 
static bool barycentric_weights (const float v1[3], const float v2[3], const float v3[3], const float co[3], const float n[3], float w[3])
 
void interp_weights_tri_v3 (float w[3], const float v1[3], const float v2[3], const float v3[3], const float co[3])
 
void interp_weights_quad_v3 (float w[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float co[3])
 
int barycentric_inside_triangle_v2 (const float w[3])
 
bool barycentric_coords_v2 (const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
 
void barycentric_weights_v2 (const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
 
void barycentric_weights_v2_clamped (const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
 
void barycentric_weights_v2_persp (const float v1[4], const float v2[4], const float v3[4], const float co[2], float w[3])
 
void barycentric_weights_v2_quad (const float v1[2], const float v2[2], const float v3[2], const float v4[2], const float co[2], float w[4])
 
void transform_point_by_tri_v3 (float pt_tar[3], float const pt_src[3], const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3], const float tri_src_p1[3], const float tri_src_p2[3], const float tri_src_p3[3])
 
void transform_point_by_seg_v3 (float p_dst[3], const float p_src[3], const float l_dst_p1[3], const float l_dst_p2[3], const float l_src_p1[3], const float l_src_p2[3])
 
int interp_sparse_array (float *array, const int list_size, const float skipval)
 
void interp_cubic_v3 (float x[3], float v[3], const float x1[3], const float v1[3], const float x2[3], const float v2[3], const float t)
 
void resolve_tri_uv_v2 (float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2])
 
void resolve_tri_uv_v3 (float r_uv[2], const float st[3], const float st0[3], const float st1[3], const float st2[3])
 
void resolve_quad_uv_v2 (float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2])
 
void resolve_quad_uv_v2_deriv (float r_uv[2], float r_deriv[2][2], const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2])
 
float resolve_quad_u_v2 (const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2])
 
void interp_bilinear_quad_v3 (float data[4][3], float u, float v, float res[3])
 
void interp_barycentric_tri_v3 (float data[3][3], float u, float v, float res[3])
 
void orthographic_m4 (float matrix[4][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip)
 
void perspective_m4 (float mat[4][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip)
 
void perspective_m4_fov (float mat[4][4], const float angle_left, const float angle_right, const float angle_up, const float angle_down, const float nearClip, const float farClip)
 
void window_translate_m4 (float winmat[4][4], float perspmat[4][4], const float x, const float y)
 
void planes_from_projmat (const float mat[4][4], float left[4], float right[4], float bottom[4], float top[4], float near[4], float far[4])
 
void projmat_dimensions (const float winmat[4][4], float *r_left, float *r_right, float *r_bottom, float *r_top, float *r_near, float *r_far)
 
void projmat_dimensions_db (const float winmat_fl[4][4], double *r_left, double *r_right, double *r_bottom, double *r_top, double *r_near, double *r_far)
 
void projmat_from_subregion (const float projmat[4][4], const int win_size[2], const int x_min, const int x_max, const int y_min, const int y_max, float r_projmat[4][4])
 
static void i_multmatrix (const float icand[4][4], float mat[4][4])
 
void polarview_m4 (float mat[4][4], float dist, float azimuth, float incidence, float twist)
 
void lookat_m4 (float mat[4][4], float vx, float vy, float vz, float px, float py, float pz, float twist)
 
int box_clip_bounds_m4 (float boundbox[2][3], const float bounds[4], float winmat[4][4])
 
void box_minmax_bounds_m4 (float min[3], float max[3], float boundbox[2][3], float mat[4][4])
 
void map_to_tube (float *r_u, float *r_v, const float x, const float y, const float z)
 
void map_to_sphere (float *r_u, float *r_v, const float x, const float y, const float z)
 
void map_to_plane_v2_v3v3 (float r_co[2], const float co[3], const float no[3])
 
void map_to_plane_axis_angle_v2_v3v3fl (float r_co[2], const float co[3], const float axis[3], const float angle)
 
void accumulate_vertex_normals_tri_v3 (float n1[3], float n2[3], float n3[3], const float f_no[3], const float co1[3], const float co2[3], const float co3[3])
 
void accumulate_vertex_normals_v3 (float n1[3], float n2[3], float n3[3], float n4[3], const float f_no[3], const float co1[3], const float co2[3], const float co3[3], const float co4[3])
 
void accumulate_vertex_normals_poly_v3 (float **vertnos, const float polyno[3], const float **vertcos, float vdiffs[][3], const int nverts)
 
void tangent_from_uv_v3 (const float uv1[2], const float uv2[2], const float uv3[2], const float co1[3], const float co2[3], const float co3[3], const float n[3], float r_tang[3])
 
void vcloud_estimate_transform_v3 (const int list_size, const float(*pos)[3], const float *weight, const float(*rpos)[3], const float *rweight, float lloc[3], float rloc[3], float lrot[3][3], float lscale[3][3])
 
static void vec_add_dir (float r[3], const float v1[3], const float v2[3], const float fac)
 
bool form_factor_visible_quad (const float p[3], const float n[3], const float v0[3], const float v1[3], const float v2[3], float q0[3], float q1[3], float q2[3], float q3[3])
 
static void ff_normalize (float n[3])
 
float form_factor_quad (const float p[3], const float n[3], const float q0[3], const float q1[3], const float q2[3], const float q3[3])
 
float form_factor_hemi_poly (float p[3], float n[3], float v1[3], float v2[3], float v3[3], float v4[3])
 
bool is_edge_convex_v3 (const float v1[3], const float v2[3], const float f1_no[3], const float f2_no[3])
 
bool is_quad_convex_v3 (const float v1[3], const float v2[3], const float v3[3], const float v4[3])
 
bool is_quad_convex_v2 (const float v1[2], const float v2[2], const float v3[2], const float v4[2])
 
bool is_poly_convex_v2 (const float verts[][2], unsigned int nr)
 
int is_quad_flip_v3 (const float v1[3], const float v2[3], const float v3[3], const float v4[3])
 
bool is_quad_flip_v3_first_third_fast (const float v1[3], const float v2[3], const float v3[3], const float v4[3])
 
bool is_quad_flip_v3_first_third_fast_with_normal (const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float normal[3])
 
float cubic_tangent_factor_circle_v3 (const float tan_l[3], const float tan_r[3])
 
float geodesic_distance_propagate_across_triangle (const float v0[3], const float v1[3], const float v2[3], const float dist1, const float dist2)
 
dist_squared_to_ray_to_aabb and helpers
void dist_squared_ray_to_aabb_v3_precalc (struct DistRayAABB_Precalc *neasrest_precalc, const float ray_origin[3], const float ray_direction[3])
 
float dist_squared_ray_to_aabb_v3 (const struct DistRayAABB_Precalc *data, const float bb_min[3], const float bb_max[3], float r_point[3], float *r_depth)
 
float dist_squared_ray_to_aabb_v3_simple (const float ray_origin[3], const float ray_direction[3], const float bb_min[3], const float bb_max[3], float r_point[3], float *r_depth)
 
dist_squared_to_projected_aabb and helpers
void dist_squared_to_projected_aabb_precalc (struct DistProjectedAABBPrecalc *precalc, const float projmat[4][4], const float winsize[2], const float mval[2])
 
float dist_squared_to_projected_aabb (struct DistProjectedAABBPrecalc *data, const float bbmin[3], const float bbmax[3], bool r_axis_closest[3])
 
float dist_squared_to_projected_aabb_simple (const float projmat[4][4], const float winsize[2], const float mval[2], const float bbmin[3], const float bbmax[3])
 
Tri-Tri Intersect 2D

"Fast and Robust Triangle-Triangle Overlap Test Using Orientation Predicates" P. Guigue - O. Devillers Journal of Graphics Tools, 8(1), 2003.

static bool isect_tri_tri_v2_impl_vert (const float t_a0[2], const float t_a1[2], const float t_a2[2], const float t_b0[2], const float t_b1[2], const float t_b2[2])
 
static bool isect_tri_tri_v2_impl_edge (const float t_a0[2], const float t_a1[2], const float t_a2[2], const float t_b0[2], const float t_b1[2], const float t_b2[2])
 
static int isect_tri_tri_impl_ccw_v2 (const float t_a0[2], const float t_a1[2], const float t_a2[2], const float t_b0[2], const float t_b1[2], const float t_b2[2])
 
bool isect_tri_tri_v2 (const float t_a0[2], const float t_a1[2], const float t_a2[2], const float t_b0[2], const float t_b1[2], const float t_b2[2])
 

interp_weights_poly_v2, v3

#define IS_POINT_IX   (1 << 0)
 
#define IS_SEGMENT_IX   (1 << 1)
 
#define DIR_V3_SET(d_len, va, vb)
 
#define DIR_V2_SET(d_len, va, vb)
 
static float mean_value_half_tan_v3 (const struct Float3_Len *d_curr, const struct Float3_Len *d_next)
 
static double mean_value_half_tan_v2_db (const struct Double2_Len *d_curr, const struct Double2_Len *d_next)
 
void interp_weights_poly_v3 (float *w, float v[][3], const int n, const float co[3])
 
void interp_weights_poly_v2 (float *w, float v[][2], const int n, const float co[2])
 

Macro Definition Documentation

◆ CCW

#define CCW (   A,
  B,
  C 
)    ((C[1] - A[1]) * (B[0] - A[0]) > (B[1] - A[1]) * (C[0] - A[0]))

◆ CROSS_SIGN

#define CROSS_SIGN (   dir_a,
  dir_b 
)     ((void)cross_v3_v3v3(test_dir, dir_a, dir_b), (dot_v3v3(plane, test_dir) > 0.0f))

◆ DIR_V2_SET

#define DIR_V2_SET (   d_len,
  va,
  vb 
)
Value:
{ \
sub_v2db_v2fl_v2fl((d_len)->dir, va, vb); \
(d_len)->len = len_v2_db((d_len)->dir); \
} \
(void)0
MINLINE double len_v2_db(const double v[2]) ATTR_WARN_UNUSED_RESULT
SyclQueue void void size_t num_bytes void
int len
Definition: draw_manager.c:108

Definition at line 4014 of file math_geom.c.

◆ DIR_V3_SET

#define DIR_V3_SET (   d_len,
  va,
  vb 
)
Value:
{ \
sub_v3_v3v3((d_len)->dir, va, vb); \
(d_len)->len = len_v3((d_len)->dir); \
} \
(void)0
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT

Definition at line 4007 of file math_geom.c.

◆ IS_POINT_IX

#define IS_POINT_IX   (1 << 0)

Definition at line 4004 of file math_geom.c.

◆ IS_SEGMENT_IX

#define IS_SEGMENT_IX   (1 << 1)

Definition at line 4005 of file math_geom.c.

◆ IS_ZERO

#define IS_ZERO (   x)    ((x > (-DBL_EPSILON) && x < DBL_EPSILON) ? 1 : 0)

Definition at line 4286 of file math_geom.c.

◆ MEAN_VALUE_HALF_TAN_V2

#define MEAN_VALUE_HALF_TAN_V2 (   _area,
  i1,
  i2 
)
Value:
((_area = cross_v2v2(dirs[i1], dirs[i2])) != 0.0f ? \
fabsf(((lens[i1] * lens[i2]) - dot_v2v2(dirs[i1], dirs[i2])) / _area) : \
0.0f)
MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint i1
#define fabsf(x)
Definition: metal/compat.h:219

Function Documentation

◆ aabb_get_near_far_from_plane()

void aabb_get_near_far_from_plane ( const float  plane_no[3],
const float  bbmin[3],
const float  bbmax[3],
float  bb_near[3],
float  bb_afar[3] 
)

Returns the coordinates of the nearest vertex and the farthest vertex from a plane (or normal).

Definition at line 615 of file math_geom.c.

Referenced by dist_squared_ray_to_aabb_v3(), dist_squared_to_projected_aabb(), DRW_culling_min_max_test(), isect_aabb_planes_v3(), and tree_intersect_plane_test().

◆ accumulate_vertex_normals_poly_v3()

void accumulate_vertex_normals_poly_v3 ( float **  vertnos,
const float  polyno[3],
const float **  vertcos,
float  vdiffs[][3],
int  nverts 
)

Add weighted face normal component into normals of the face vertices. Caller must pass pre-allocated vdiffs of nverts length.

Definition at line 5061 of file math_geom.c.

References dot_v3v3(), madd_v3_v3fl(), normalize_v3(), saacos(), and sub_v3_v3v3().

◆ accumulate_vertex_normals_tri_v3()

void accumulate_vertex_normals_tri_v3 ( float  n1[3],
float  n2[3],
float  n3[3],
const float  f_no[3],
const float  co1[3],
const float  co2[3],
const float  co3[3] 
)

Definition at line 4977 of file math_geom.c.

References dot_v3v3(), madd_v3_v3fl(), normalize_v3(), saacos(), sub_v3_v3v3(), and vn.

Referenced by BKE_mesh_calc_normals_looptri().

◆ accumulate_vertex_normals_v3()

void accumulate_vertex_normals_v3 ( float  n1[3],
float  n2[3],
float  n3[3],
float  n4[3],
const float  f_no[3],
const float  co1[3],
const float  co2[3],
const float  co3[3],
const float  co4[3] 
)

Definition at line 5014 of file math_geom.c.

References dot_v3v3(), madd_v3_v3fl(), normalize_v3(), NULL, saacos(), sub_v3_v3v3(), and vn.

Referenced by make_face().

◆ area_poly_signed_v2()

float area_poly_signed_v2 ( const float  verts[][2],
unsigned int  nr 
)

Definition at line 179 of file math_geom.c.

References cross_poly_v2(), and verts.

Referenced by area_squared_poly_v2().

◆ area_poly_v2()

float area_poly_v2 ( const float  verts[][2],
unsigned int  nr 
)

◆ area_poly_v3()

float area_poly_v3 ( const float  verts[][3],
unsigned int  nr 
)

◆ area_quad_v3()

float area_quad_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3] 
)

Definition at line 77 of file math_geom.c.

References area_poly_v3(), UNPACK3, v1, v2, and verts.

Referenced by psys_thread_context_init_distribute().

◆ area_squared_poly_v2()

float area_squared_poly_v2 ( const float  verts[][2],
unsigned int  nr 
)

Definition at line 184 of file math_geom.c.

References blender::compositor::area(), area_poly_signed_v2(), and verts.

◆ area_squared_poly_v3()

float area_squared_poly_v3 ( const float  verts[][3],
unsigned int  nr 
)

Definition at line 132 of file math_geom.c.

References cross_poly_v3(), len_squared_v3(), mul_v3_fl(), and verts.

Referenced by area_squared_quad_v3().

◆ area_squared_quad_v3()

float area_squared_quad_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3] 
)

Definition at line 83 of file math_geom.c.

References area_squared_poly_v3(), UNPACK3, v1, v2, and verts.

◆ area_squared_tri_v3()

float area_squared_tri_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3] 
)

Definition at line 99 of file math_geom.c.

References cross_tri_v3(), len_squared_v3(), mul_v3_fl(), v1, and v2.

Referenced by BM_face_calc_point_in_face().

◆ area_tri_signed_v3()

float area_tri_signed_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  normal[3] 
)

Definition at line 107 of file math_geom.c.

References blender::compositor::area(), cross_tri_v3(), dot_v3v3(), len_v3(), normal, v1, and v2.

Referenced by mesh_calc_poly_area_centroid().

◆ area_tri_v3()

float area_tri_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3] 
)

◆ axis_dominant_v3_to_m3()

void axis_dominant_v3_to_m3 ( float  r_mat[3][3],
const float  normal[3] 
)

◆ axis_dominant_v3_to_m3_negate()

void axis_dominant_v3_to_m3_negate ( float  r_mat[3][3],
const float  normal[3] 
)

◆ barycentric_coords_v2()

bool barycentric_coords_v2 ( const float  v1[2],
const float  v2[2],
const float  v3[2],
const float  co[2],
float  w[3] 
)

◆ barycentric_inside_triangle_v2()

int barycentric_inside_triangle_v2 ( const float  w[3])
Returns
  • 0 if the point is outside of triangle.
  • 1 if the point is inside triangle.
  • 2 if it's on the edge.

Definition at line 3663 of file math_geom.c.

References IN_RANGE, IN_RANGE_INCL, and w().

Referenced by blender::compositor::KeyingScreenOperation::execute_pixel(), blender::bke::pbvh::pixels::extract_barycentric_pixels(), and blender::compositor::KeyingScreenOperation::update_memory_buffer_partial().

◆ barycentric_weights()

static bool barycentric_weights ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  co[3],
const float  n[3],
float  w[3] 
)
static

◆ barycentric_weights_v2()

void barycentric_weights_v2 ( const float  v1[2],
const float  v2[2],
const float  v3[2],
const float  co[2],
float  w[3] 
)

◆ barycentric_weights_v2_clamped()

void barycentric_weights_v2_clamped ( const float  v1[2],
const float  v2[2],
const float  v3[2],
const float  co[2],
float  w[3] 
)

A version of barycentric_weights_v2 that doesn't allow negative weights. Useful when negative values cause problems and points are only ever slightly outside of the triangle.

Definition at line 3723 of file math_geom.c.

References copy_v3_fl(), cross_tri_v2(), is_finite_v3(), max_ff(), mul_v3_fl(), v1, v2, and w().

Referenced by tri_fill_smooth().

◆ barycentric_weights_v2_persp()

void barycentric_weights_v2_persp ( const float  v1[4],
const float  v2[4],
const float  v3[4],
const float  co[2],
float  w[3] 
)

still use 2D X,Y space but this works for verts transformed by a perspective matrix, using their 4th component as a weight

Definition at line 3746 of file math_geom.c.

References copy_v3_fl(), cross_tri_v2(), is_finite_v3(), mul_v3_fl(), v1, v2, and w().

Referenced by project_bucket_clip_face(), project_paint_occlude_ptv_clip(), rect_to_uvspace_persp(), and VecZDepthPersp().

◆ barycentric_weights_v2_quad()

void barycentric_weights_v2_quad ( const float  v1[2],
const float  v2[2],
const float  v3[2],
const float  v4[2],
const float  co[2],
float  w[4] 
)

same as barycentric_weights_v2 but works with a quad, NOTE: untested for values outside the quad's bounds this is interp_weights_poly_v2 expanded for quads only

Definition at line 3769 of file math_geom.c.

References blender::compositor::area(), copy_v4_fl(), is_finite_v4(), len_v2(), MEAN_VALUE_HALF_TAN_V2, mul_v4_fl(), t, UNLIKELY, v1, v2, and w().

Referenced by barycentric_weights_v2_grid_cache(), draw_circle_in_quad(), and maskrasterize_layer_z_depth_quad().

◆ box_clip_bounds_m4()

int box_clip_bounds_m4 ( float  boundbox[2][3],
const float  bounds[4],
float  winmat[4][4] 
)

Definition at line 4835 of file math_geom.c.

References Freestyle::a, bounds(), copy_m4_m4(), and mul_m4_v4().

◆ box_minmax_bounds_m4()

void box_minmax_bounds_m4 ( float  min[3],
float  max[3],
float  boundbox[2][3],
float  mat[4][4] 
)

Definition at line 4894 of file math_geom.c.

References Freestyle::a, copy_v3_v3(), max, min, minmax_v3v3_v3(), and mul_m4_v3().

◆ clip_segment_v3_plane()

bool clip_segment_v3_plane ( const float  p1[3],
const float  p2[3],
const float  plane[4],
float  r_p1[3],
float  r_p2[3] 
)

◆ clip_segment_v3_plane_n()

bool clip_segment_v3_plane_n ( const float  p1[3],
const float  p2[3],
const float  plane_array[][4],
const int  plane_num,
float  r_p1[3],
float  r_p2[3] 
)

◆ closest_on_tri_to_point_v3()

void closest_on_tri_to_point_v3 ( float  r[3],
const float  p[3],
const float  v1[3],
const float  v2[3],
const float  v3[3] 
)

◆ closest_seg_seg_v2()

float closest_seg_seg_v2 ( float  r_closest_a[2],
float  r_closest_b[2],
float r_lambda_a,
float r_lambda_b,
const float  a1[2],
const float  a2[2],
const float  b1[2],
const float  b2[2] 
)

Finds the points where two line segments are closest to each other.

lambda_* is a value between 0 and 1 for each segment that indicates where r_closest_* is on the corresponding segment.

Returns
Squared distance between both segments.

Definition at line 297 of file math_geom.c.

References BLI_assert, closest_to_line_segment_v2(), closest_to_line_v2(), copy_v2_v2(), isect_line_line_v2_point(), isect_seg_seg_v2_simple(), len_squared_v2v2(), and min_ffff().

◆ closest_to_line_segment_v2()

float closest_to_line_segment_v2 ( float  r_close[2],
const float  p[2],
const float  l1[2],
const float  l2[2] 
)

Point closest to v1 on line v2-v3 in 2D.

Returns
A value in [0, 1] that corresponds to the position of #r_close on the line segment.

Definition at line 357 of file math_geom.c.

References closest_to_line_v2(), and copy_v2_v2().

Referenced by closest_seg_seg_v2(), dist_squared_to_line_segment_v2(), edbm_rip_edge_invoke(), knife_find_line_hits(), uv_find_nearest_edge(), and uvedit_uv_straighten_elements().

◆ closest_to_line_segment_v3()

float closest_to_line_segment_v3 ( float  r_close[3],
const float  p[3],
const float  l1[3],
const float  l2[3] 
)

◆ closest_to_line_v2()

float closest_to_line_v2 ( float  r_close[2],
const float  p[2],
const float  l1[2],
const float  l2[2] 
)

◆ closest_to_line_v2_db()

double closest_to_line_v2_db ( double  r_close[2],
const double  p[2],
const double  l1[2],
const double  l2[2] 
)

Definition at line 3200 of file math_geom.c.

References dot_v2v2_db(), and sub_v2_v2v2_db().

◆ closest_to_line_v3()

float closest_to_line_v3 ( float  r_close[3],
const float  p[3],
const float  l1[3],
const float  l2[3] 
)

◆ closest_to_plane3_normalized_v3()

void closest_to_plane3_normalized_v3 ( float  r_close[3],
const float  plane[3],
const float  pt[3] 
)

Definition at line 422 of file math_geom.c.

References BLI_ASSERT_UNIT_V3, dot_v3v3(), and madd_v3_v3v3fl().

◆ closest_to_plane3_v3()

void closest_to_plane3_v3 ( float  r_close[3],
const float  plane[3],
const float  pt[3] 
)

Definition at line 415 of file math_geom.c.

References dot_v3v3(), len_squared_v3(), and madd_v3_v3v3fl().

◆ closest_to_plane_normalized_v3()

void closest_to_plane_normalized_v3 ( float  r_close[3],
const float  plane[4],
const float  pt[3] 
)

◆ closest_to_plane_v3()

void closest_to_plane_v3 ( float  r_close[3],
const float  plane[4],
const float  pt[3] 
)

Find the closest point on a plane.

Parameters
r_closeReturn coordinate
planeThe plane to test against.
ptThe point to find the nearest of
Note
non-unit-length planes are supported.

Definition at line 401 of file math_geom.c.

References len_squared_v3(), madd_v3_v3v3fl(), and plane_point_side_v3().

Referenced by BM_mesh_bisect_plane(), cloth_brush_solve_collision(), ED_view3d_win_to_3d_on_plane_with_fallback(), gpencil_sculpt_compute_lock_axis(), isect_point_tri_v3(), project_line_gesture_apply_task_cb(), SCULPT_relax_vertex(), and snap_to_pipe_profile().

◆ closest_to_ray_v3()

float closest_to_ray_v3 ( float  r_close[3],
const float  p[3],
const float  ray_orig[3],
const float  ray_dir[3] 
)

◆ cotangent_tri_weight_v3()

float cotangent_tri_weight_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3] 
)

◆ cross_poly_v2()

float cross_poly_v2 ( const float  verts[][2],
unsigned int  nr 
)

Scalar cross product of a 2d polygon.

  • equivalent to area * 2
  • useful for checking polygon winding (a positive value is clockwise).

Definition at line 141 of file math_geom.c.

References Freestyle::a, blender::math::cross(), and verts.

Referenced by area_poly_signed_v2(), area_poly_v2(), BKE_mesh_uv_vert_map_create(), BM_face_uv_calc_cross(), BM_uv_element_map_create(), BM_uv_vert_map_create(), and polyfill_prepare().

◆ cross_poly_v3()

void cross_poly_v3 ( float  n[3],
const float  verts[][3],
unsigned int  nr 
)

Definition at line 160 of file math_geom.c.

References add_newell_cross_v3_v3v3(), verts, and zero_v3().

Referenced by area_poly_v3(), area_squared_poly_v3(), and normal_poly_v3().

◆ cross_tri_v3()

void cross_tri_v3 ( float  n[3],
const float  v1[3],
const float  v2[3],
const float  v3[3] 
)

◆ cubic_tangent_factor_circle_v3()

float cubic_tangent_factor_circle_v3 ( const float  tan_l[3],
const float  tan_r[3] 
)

Return the value which the distance between points will need to be scaled by, to define a handle, given both points are on a perfect circle.

Use when we want a bezier curve to match a circle as closely as possible.

Note
the return value will need to be divided by 0.75 for correct results.

Definition at line 5895 of file math_geom.c.

References acosf, angle(), BLI_ASSERT_UNIT_V3, cosf, dot_v3v3(), eps, and sinf.

Referenced by BKE_pchan_bbone_handles_compute().

◆ dist_seg_seg_v2()

float dist_seg_seg_v2 ( const float  a1[3],
const float  a2[3],
const float  b1[3],
const float  b2[3] 
)

Returns the distance between two 2D line segments.

Definition at line 968 of file math_geom.c.

References dist_squared_to_line_segment_v2(), isect_seg_seg_v2_simple(), min_ffff(), and sqrtf.

◆ dist_signed_squared_to_corner_v3v3v3()

float dist_signed_squared_to_corner_v3v3v3 ( const float  p[3],
const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  axis_ref[3] 
)

Check if p is inside the 2x planes defined by (v1, v2, v3) where the 3x points define 2x planes.

Parameters
axis_refused when v1,v2,v3 form a line and to check if the corner is concave/convex.
Note
the distance from v1 & v3 to v2 doesn't matter (it just defines the planes).
Returns
the lowest squared distance to either of the planes. where (return < 0.0) is outside.
v1
+
/
x - out / x - inside
/
+----+
v2 v3
x - also outside

Definition at line 512 of file math_geom.c.

References copy_v3_v3(), cross_v3_v3v3(), dist_signed_squared_to_plane3_v3(), dist_signed_squared_to_plane_v3(), dot_v3v3(), len_squared_v3(), max_ff(), min_ff(), negate_v3(), plane_from_point_normal_v3(), sub_v3_v3v3(), v1, and v2.

Referenced by BM_loop_point_side_of_loop_test(), and tc_mesh_customdatacorrect_apply_vert().

◆ dist_signed_squared_to_plane3_v3()

float dist_signed_squared_to_plane3_v3 ( const float  pt[3],
const float  plane[3] 
)

Definition at line 445 of file math_geom.c.

References copysignf, dot_v3v3(), and len_squared_v3().

Referenced by dist_signed_squared_to_corner_v3v3v3().

◆ dist_signed_squared_to_plane_v3()

float dist_signed_squared_to_plane_v3 ( const float  pt[3],
const float  plane[4] 
)

◆ dist_signed_to_plane3_v3()

float dist_signed_to_plane3_v3 ( const float  pt[3],
const float  plane[3] 
)

Definition at line 473 of file math_geom.c.

References dot_v3v3(), len_squared_v3(), and sqrtf.

Referenced by dist_to_plane3_v3().

◆ dist_signed_to_plane_v3()

float dist_signed_to_plane_v3 ( const float  p[3],
const float  plane[4] 
)

◆ dist_squared_ray_to_aabb_v3()

float dist_squared_ray_to_aabb_v3 ( const struct DistRayAABB_Precalc data,
const float  bb_min[3],
const float  bb_max[3],
float  r_point[3],
float r_depth 
)

Returns the distance from a ray to a bound-box (projected on ray)

Definition at line 665 of file math_geom.c.

References aabb_get_near_far_from_plane(), copy_v3_v3(), data, dist_squared_ray_to_seg_v3(), dot_v3v3(), and sub_v3_v3v3().

Referenced by dist_squared_ray_to_aabb_v3_simple(), nearest_to_ray_aabb_dist_sq(), and SCULPT_search_circle_cb().

◆ dist_squared_ray_to_aabb_v3_precalc()

void dist_squared_ray_to_aabb_v3_precalc ( struct DistRayAABB_Precalc neasrest_precalc,
const float  ray_origin[3],
const float  ray_direction[3] 
)

◆ dist_squared_ray_to_aabb_v3_simple()

float dist_squared_ray_to_aabb_v3_simple ( const float  ray_origin[3],
const float  ray_direction[3],
const float  bb_min[3],
const float  bb_max[3],
float  r_point[3],
float r_depth 
)

Use when there is no advantage to pre-calculation.

Definition at line 754 of file math_geom.c.

References data, dist_squared_ray_to_aabb_v3(), dist_squared_ray_to_aabb_v3_precalc(), DistRayAABB_Precalc::ray_direction, and DistRayAABB_Precalc::ray_origin.

◆ dist_squared_ray_to_seg_v3()

float dist_squared_ray_to_seg_v3 ( const float  ray_origin[3],
const float  ray_direction[3],
const float  v0[3],
const float  v1[3],
float  r_point[3],
float r_depth 
)

Find the closest point in a seg to a ray and return the distance squared.

Parameters
r_pointIs the point on segment closest to ray (or to ray_origin if the ray and the segment are parallel).
r_depththe distance of r_point projection on ray to the ray_origin.

Definition at line 579 of file math_geom.c.

References copy_v3_v3(), dot_v3v3(), interp_v3_v3v3(), isect_ray_line_v3(), len_squared_v3(), square_f(), sub_v3_v3v3(), and v1.

Referenced by dist_squared_ray_to_aabb_v3(), dist_squared_ray_to_tri_v3_fast(), and EDBM_unified_findnearest_from_raycast().

◆ dist_squared_to_line_segment_v2()

float dist_squared_to_line_segment_v2 ( const float  p[2],
const float  l1[2],
const float  l2[2] 
)

◆ dist_squared_to_line_segment_v3()

float dist_squared_to_line_segment_v3 ( const float  p[3],
const float  l1[3],
const float  l2[3] 
)

◆ dist_squared_to_line_v2()

float dist_squared_to_line_v2 ( const float  p[2],
const float  l1[2],
const float  l2[2] 
)

Distance p to line v1-v2 using Hesse formula (NO LINE PIECE!)

Definition at line 270 of file math_geom.c.

References closest(), closest_to_line_v2(), and len_squared_v2v2().

Referenced by dist_to_line_v2(), freetypechar_to_vchar(), project_bucket_clip_face(), and testvertexnearedge().

◆ dist_squared_to_line_v3()

float dist_squared_to_line_v3 ( const float  p[3],
const float  l1[3],
const float  l2[3] 
)

Definition at line 499 of file math_geom.c.

References closest(), closest_to_line_v3(), and len_squared_v3v3().

Referenced by BKE_nurb_handles_autocalc(), and dist_to_line_v3().

◆ dist_squared_to_plane3_v3()

float dist_squared_to_plane3_v3 ( const float  pt[3],
const float  plane[3] 
)

Definition at line 452 of file math_geom.c.

References dot_v3v3(), and len_squared_v3().

◆ dist_squared_to_plane_v3()

float dist_squared_to_plane_v3 ( const float  pt[3],
const float  plane[4] 
)

Definition at line 436 of file math_geom.c.

References len_squared_v3(), and plane_point_side_v3().

Referenced by build_boundary_terminal_edge(), and knife_ray_intersect_face().

◆ dist_squared_to_projected_aabb()

float dist_squared_to_projected_aabb ( struct DistProjectedAABBPrecalc data,
const float  bbmin[3],
const float  bbmax[3],
bool  r_axis_closest[3] 
)

◆ dist_squared_to_projected_aabb_precalc()

void dist_squared_to_projected_aabb_precalc ( struct DistProjectedAABBPrecalc precalc,
const float  projmat[4][4],
const float  winsize[2],
const float  mval[2] 
)

◆ dist_squared_to_projected_aabb_simple()

float dist_squared_to_projected_aabb_simple ( const float  projmat[4][4],
const float  winsize[2],
const float  mval[2],
const float  bbmin[3],
const float  bbmax[3] 
)

◆ dist_squared_to_ray_v3_normalized()

float dist_squared_to_ray_v3_normalized ( const float  ray_origin[3],
const float  ray_direction[3],
const float  co[3] 
)

Compute the squared distance of a point to a line (defined as ray).

Parameters
ray_originA point on the line.
ray_directionNormalized direction of the line.
coPoint to which the distance is to be calculated.

Definition at line 563 of file math_geom.c.

References add_v3_v3v3(), len_squared_v3v3(), project_v3_v3v3_normalized(), and sub_v3_v3v3().

Referenced by EDBM_unified_findnearest_from_raycast().

◆ dist_to_line_segment_v2()

float dist_to_line_segment_v2 ( const float  p[2],
const float  l1[2],
const float  l2[2] 
)

Definition at line 292 of file math_geom.c.

References dist_squared_to_line_segment_v2(), and sqrtf.

Referenced by MOD_lineart_smooth_chains(), and TEST().

◆ dist_to_line_segment_v3()

float dist_to_line_segment_v3 ( const float  p[3],
const float  l1[3],
const float  l2[3] 
)

Definition at line 494 of file math_geom.c.

References dist_squared_to_line_segment_v3(), and sqrtf.

◆ dist_to_line_v2()

float dist_to_line_v2 ( const float  p[2],
const float  l1[2],
const float  l2[2] 
)

◆ dist_to_line_v3()

float dist_to_line_v3 ( const float  p[3],
const float  l1[3],
const float  l2[3] 
)

◆ dist_to_plane3_v3()

float dist_to_plane3_v3 ( const float  pt[3],
const float  plane[3] 
)

Definition at line 480 of file math_geom.c.

References dist_signed_to_plane3_v3(), and fabsf.

◆ dist_to_plane_v3()

float dist_to_plane_v3 ( const float  pt[3],
const float  plane[4] 
)

Definition at line 468 of file math_geom.c.

References dist_signed_to_plane_v3(), and fabsf.

Referenced by do_cloth_brush_apply_forces_task_cb_ex().

◆ ff_normalize()

static void ff_normalize ( float  n[3])
static

Definition at line 5656 of file math_geom.c.

References dot_v3v3(), and sqrtf.

Referenced by form_factor_quad().

◆ form_factor_hemi_poly()

float form_factor_hemi_poly ( float  p[3],
float  n[3],
float  v1[3],
float  v2[3],
float  v3[3],
float  v4[3] 
)

Definition at line 5716 of file math_geom.c.

References form_factor_quad(), form_factor_visible_quad(), q1, v1, and v2.

◆ form_factor_quad()

float form_factor_quad ( const float  p[3],
const float  n[3],
const float  q0[3],
const float  q1[3],
const float  q2[3],
const float  q3[3] 
)

Definition at line 5671 of file math_geom.c.

References cross_v3_v3v3(), dot3(), dot_v3v3(), ff_normalize(), M_PI, MAX2, q1, result, saacosf(), and sub_v3_v3v3().

Referenced by form_factor_hemi_poly().

◆ form_factor_visible_quad()

bool form_factor_visible_quad ( const float  p[3],
const float  n[3],
const float  v0[3],
const float  v1[3],
const float  v2[3],
float  q0[3],
float  q1[3],
float  q2[3],
float  q3[3] 
)

◆ geodesic_distance_propagate_across_triangle()

float geodesic_distance_propagate_across_triangle ( const float  v0[3],
const float  v1[3],
const float  v2[3],
float  dist1,
float  dist2 
)

Utility for computing approximate geodesic distances on triangle meshes.

Given triangle with vertex coordinates v0, v1, v2, and known geodesic distances dist1 and dist2 at v1 and v2, estimate a geodesic distance at vertex v0.

From "Dart Throwing on Surfaces", EGSR 2009. Section 7, Geodesic Dart Throwing.

Definition at line 5922 of file math_geom.c.

References Freestyle::a, cross_v3_v3v3(), dot_v3v3(), fabsf, len_v2v2(), len_v3(), len_v3v3(), min_ff(), normalize_v3(), normalize_v3_v3(), sqrtf, sub_v3_v3v3(), v, v1, and v2.

Referenced by bmesh_test_dist_add(), and sculpt_geodesic_mesh_test_dist_add().

◆ getLowestRoot()

static bool getLowestRoot ( const float  a,
const float  b,
const float  c,
const float  maxR,
float root 
)
static

Definition at line 2568 of file math_geom.c.

References Freestyle::a, usdtokens::b(), Freestyle::c, determinant(), sqrtf, and SWAP.

Referenced by isect_sweeping_sphere_tri_v3().

◆ i_multmatrix()

static void i_multmatrix ( const float  icand[4][4],
float  mat[4][4] 
)
static

Definition at line 4758 of file math_geom.c.

References col, and copy_m4_m4().

Referenced by lookat_m4().

◆ interp_barycentric_tri_v3()

void interp_barycentric_tri_v3 ( float  data[3][3],
float  u,
float  v,
float  res[3] 
)

◆ interp_bilinear_quad_v3()

void interp_bilinear_quad_v3 ( float  data[4][3],
float  u,
float  v,
float  res[3] 
)

Use to find the point of a UV on a face. Reverse of resolve_* functions.

Definition at line 4484 of file math_geom.c.

References add_v3_v3(), copy_v3_v3(), data, mul_v3_fl(), and v.

Referenced by interp_bilinear_grid(), interp_bilinear_mpoly(), and interp_vmesh().

◆ interp_cubic_v3()

void interp_cubic_v3 ( float  x[3],
float  v[3],
const float  x1[3],
const float  v1[3],
const float  x2[3],
const float  v2[3],
float  t 
)

(x1, v1)(t1=0)------(x2, v2)(t2=1), 0<t<1 --> (x, v)(t).

Definition at line 4253 of file math_geom.c.

References Freestyle::a, usdtokens::b(), t, v, v1, v2, x, and x2.

Referenced by psys_interpolate_particle().

◆ interp_sparse_array()

int interp_sparse_array ( float array,
int  list_size,
float  skipval 
)

Given an array with some invalid values this function interpolates valid values replacing the invalid ones.

Definition at line 3917 of file math_geom.c.

References float(), MEM_callocN, and MEM_freeN.

Referenced by annotation_stroke_newfrombuffer(), gpencil_get_depth_array(), gpencil_primitive_update_strokes(), and gpencil_stroke_newfrombuffer().

◆ interp_weights_poly_v2()

void interp_weights_poly_v2 ( float w,
float  v[][2],
const int  n,
const float  co[2] 
)

◆ interp_weights_poly_v3()

void interp_weights_poly_v3 ( float w,
float  v[][3],
const int  n,
const float  co[3] 
)

◆ interp_weights_quad_v3()

void interp_weights_quad_v3 ( float  w[4],
const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3],
const float  co[3] 
)

◆ interp_weights_tri_v3()

void interp_weights_tri_v3 ( float  w[3],
const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  co[3] 
)

◆ is_edge_convex_v3()

bool is_edge_convex_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3] 
)

Check if the edge is convex or concave (depends on face winding) Copied from BM_edge_is_convex().

Definition at line 5734 of file math_geom.c.

References blender::math::cross(), cross_v3_v3v3(), dot_v3v3(), equals_v3v3(), sub_v3_v3v3(), v1, and v2.

Referenced by blender::draw::statvis_calc_sharp().

◆ is_poly_convex_v2()

bool is_poly_convex_v2 ( const float  verts[][2],
unsigned int  nr 
)

◆ is_quad_convex_v2()

bool is_quad_convex_v2 ( const float  v1[2],
const float  v2[2],
const float  v3[2],
const float  v4[2] 
)

Definition at line 5800 of file math_geom.c.

References isect_seg_seg_v2(), v1, and v2.

◆ is_quad_convex_v3()

bool is_quad_convex_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3] 
)

Evaluate if entire quad is a proper convex quad

Method projects points onto a plane and checks its convex using following method:

  • Create a plane from the cross-product of both diagonal vectors.
  • Project all points onto the plane.
  • Subtract for direction vectors.
  • Return true if all corners cross-products point the direction of the plane.

Definition at line 5750 of file math_geom.c.

References CROSS_SIGN, cross_v3_v3v3(), len_squared_v3(), project_plane_v3_v3v3(), sub_v3_v3v3(), v1, and v2.

Referenced by bm_decim_triangulate_end(), and hull_merge_triangles().

◆ is_quad_flip_v3()

int is_quad_flip_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3] 
)

Check if either of the diagonals along this quad create flipped triangles (normals pointing away from each other).

  • (1 << 0): (v1-v3) is flipped.
  • (1 << 1): (v2-v4) is flipped.

Definition at line 5845 of file math_geom.c.

References cross_v3_v3v3(), dot_v3v3(), ret, sub_v3_v3v3(), v1, and v2.

Referenced by bm_edge_is_delimit(), BM_face_triangulate(), and bm_vert_connect_select_history_edge_to_vert_path().

◆ is_quad_flip_v3_first_third_fast()

bool is_quad_flip_v3_first_third_fast ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3] 
)

Definition at line 5867 of file math_geom.c.

References cross_v3_v3v3(), dot_v3v3(), sub_v3_v3v3(), v1, and v2.

Referenced by mesh_calc_tessellation_for_face_impl().

◆ is_quad_flip_v3_first_third_fast_with_normal()

bool is_quad_flip_v3_first_third_fast_with_normal ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3],
const float  normal[3] 
)

◆ isect_aabb_aabb_v3()

bool isect_aabb_aabb_v3 ( const float  min1[3],
const float  max1[3],
const float  min2[3],
const float  max2[3] 
)

Axis-aligned bounding box.

Definition at line 3048 of file math_geom.c.

Referenced by blender::ed::sculpt_paint::paint::image::init_triangle_brush_test(), and particle_intersect_mesh().

◆ isect_aabb_planes_v3()

int isect_aabb_planes_v3 ( const float(*)  planes[4],
int  totplane,
const float  bbmin[3],
const float  bbmax[3] 
)

Checks status of an AABB in relation to a list of planes.

Returns
intersection type:
  • ISECT_AABB_PLANE_BEHIND_ONE (0): AABB is completely behind at least 1 plane;
  • ISECT_AABB_PLANE_CROSS_ANY (1): AABB intersects at least 1 plane;
  • ISECT_AABB_PLANE_IN_FRONT_ALL (2): AABB is completely in front of all planes;

Definition at line 2604 of file math_geom.c.

References aabb_get_near_far_from_plane(), ISECT_AABB_PLANE_BEHIND_ANY, ISECT_AABB_PLANE_CROSS_ANY, ISECT_AABB_PLANE_IN_FRONT_ALL, plane_point_side_v3(), and ret.

Referenced by BLI_bvhtree_find_nearest_projected(), and bvhtree_nearest_projected_with_clipplane_test_dfs_recursive().

◆ isect_axial_line_segment_tri_v3()

bool isect_axial_line_segment_tri_v3 ( const int  axis,
const float  p1[3],
const float  p2[3],
const float  v0[3],
const float  v1[3],
const float  v2[3],
float r_lambda 
)

Definition at line 2819 of file math_geom.c.

References blender::robust_pred::epsilon, sub_v3_v3v3(), v, v1, and v2.

◆ isect_line_line_epsilon_v3()

int isect_line_line_epsilon_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3],
float  i1[3],
float  i2[3],
float  epsilon 
)
Returns
The number of point of interests 0 - lines are collinear 1 - lines are coplanar, i1 is set to intersection 2 - i1 and i2 are the nearest points on line 1 (v1, v2) and line 2 (v3, v4) respectively

Definition at line 2871 of file math_geom.c.

References Freestyle::a, add_v3_v3v3(), usdtokens::b(), Freestyle::c, copy_v3_v3(), cross_v3_v3v3(), dot_v3v3(), blender::robust_pred::epsilon, fabsf, mul_v3_fl(), project_v3_v3v3(), sub_v3_v3v3(), t, UNLIKELY, v1, and v2.

Referenced by isect_line_line_v3().

◆ isect_line_line_strict_v3()

bool isect_line_line_strict_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3],
float  vi[3],
float r_lambda 
)

Intersection point strictly between the two lines

Returns
false when no intersection is found.

Definition at line 2946 of file math_geom.c.

References Freestyle::a, add_v3_v3v3(), usdtokens::b(), Freestyle::c, cross_v3_v3v3(), dot_v3v3(), blender::robust_pred::epsilon, fabsf, mul_v3_fl(), sub_v3_v3v3(), UNLIKELY, v1, and v2.

◆ isect_line_line_v2_point()

int isect_line_line_v2_point ( const float  v0[2],
const float  v1[2],
const float  v2[2],
const float  v3[2],
float  r_vi[2] 
)

Intersect Line-Line, floats - gives intersection point.

Definition at line 1085 of file math_geom.c.

References cross_v2v2(), ISECT_LINE_LINE_COLINEAR, ISECT_LINE_LINE_CROSS, sub_v2_v2v2(), v, v1, and v2.

Referenced by closest_seg_seg_v2(), facetag_cut_cost_edge_uv(), and knife_snap_edge_constrained().

◆ isect_line_line_v3()

int isect_line_line_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3],
float  r_i1[3],
float  r_i2[3] 
)

◆ isect_line_plane_v3()

bool isect_line_plane_v3 ( float  r_isect_co[3],
const float  l1[3],
const float  l2[3],
const float  plane_co[3],
const float  plane_no[3] 
)

Intersect line/plane.

Parameters
r_isect_coThe intersection point.
l1The first point of the line.
l2The second point of the line.
plane_coA point on the plane to intersect with.
plane_noThe direction of the plane (does not need to be normalized).
Note
line_plane_factor_v3() shares logic.

Definition at line 2078 of file math_geom.c.

References blender::math::dot(), dot_v3v3(), fabsf, madd_v3_v3v3fl(), and sub_v3_v3v3().

Referenced by adjust_miter_coords(), bindVert(), bm_loop_calc_opposite_co(), calculate_profile_segments(), compute_collision_point_edge_tri(), compute_collision_point_tri_tri(), ED_gpencil_project_point_to_plane(), ED_gpencil_project_stroke_to_plane(), knife_start_cut(), knife_update_active(), and M_Geometry_intersect_line_plane().

◆ isect_line_segment_tri_epsilon_v3()

bool isect_line_segment_tri_epsilon_v3 ( const float  p1[3],
const float  p2[3],
const float  v0[3],
const float  v1[3],
const float  v2[3],
float r_lambda,
float  r_uv[2],
float  epsilon 
)

Like isect_line_segment_tri_v3, but allows epsilon tolerance around triangle.

Definition at line 1611 of file math_geom.c.

References Freestyle::a, cross_v3_v3v3(), dot_v3v3(), blender::robust_pred::epsilon, sub_v3_v3v3(), v, v1, and v2.

◆ isect_line_segment_tri_v3()

bool isect_line_segment_tri_v3 ( const float  p1[3],
const float  p2[3],
const float  v0[3],
const float  v1[3],
const float  v2[3],
float r_lambda,
float  r_uv[2] 
)

Test if the line starting at p1 ending at p2 intersects the triangle v0..v2 return non zero if it does.

Definition at line 1561 of file math_geom.c.

References Freestyle::a, cross_v3_v3v3(), dot_v3v3(), sub_v3_v3v3(), v, v1, and v2.

Referenced by compute_collision_point_edge_tri(), particle_intersect_mesh(), sb_detect_edge_collisionCached(), and sb_detect_face_collisionCached().

◆ isect_line_sphere_v2()

int isect_line_sphere_v2 ( const float  l1[2],
const float  l2[2],
const float  sp[2],
const float  r,
float  r_p1[2],
float  r_p2[2] 
)

◆ isect_line_sphere_v3()

int isect_line_sphere_v3 ( const float  l1[3],
const float  l2[3],
const float  sp[3],
float  r,
float  r_p1[3],
float  r_p2[3] 
)
Parameters
l1,l2Coordinates (point of line).
sp,rCoordinate and radius (sphere).
Returns
r_p1, r_p2: Intersection coordinates.
Note
The order of assignment for intersection points (r_p1, r_p2) is predictable, based on the direction defined by l2 - l1, this direction compared with the normal of each point on the sphere: r_p1 always has a >= 0.0 dot product. r_p2 always has a <= 0.0 dot product. For example, when l1 is inside the sphere and l2 is outside, r_p1 will always be between l1 and l2.

Definition at line 1349 of file math_geom.c.

References Freestyle::a, usdtokens::b(), Freestyle::c, dot_v3v3(), len_squared_v3(), madd_v3_v3v3fl(), r, and sqrtf.

Referenced by M_Geometry_intersect_line_sphere().

◆ isect_plane_plane_plane_v3()

bool isect_plane_plane_plane_v3 ( const float  plane_a[4],
const float  plane_b[4],
const float  plane_c[4],
float  r_isect_co[3] 
)

Intersect three planes, return the point where all 3 meet. See Graphics Gems 1 pg 305

Parameters
plane_a,plane_b,plane_cPlanes.
r_isect_coThe resulting intersection point.

Definition at line 2101 of file math_geom.c.

References cross_v3_v3v3(), determinant_m3(), madd_v3_v3fl(), mul_v3_fl(), mul_v3_v3fl(), and UNPACK3.

Referenced by blender::nodes::node_geo_curve_primitive_arc_cc::create_arc_curve_from_points(), blender::nodes::node_geo_curve_primitive_circle_cc::create_point_circle_curve(), dist_squared_to_projected_aabb_precalc(), and interp_slerp_co_no_v3().

◆ isect_plane_plane_v3()

bool isect_plane_plane_v3 ( const float  plane_a[4],
const float  plane_b[4],
float  r_isect_co[3],
float  r_isect_no[3] 
)

Intersect two planes, return a point on the intersection and a vector that runs on the direction of the intersection.

Note
this is a slightly reduced version of isect_plane_plane_plane_v3
Parameters
plane_a,plane_bPlanes.
r_isect_coThe resulting intersection point.
r_isect_noThe resulting vector of the intersection.
Note
r_isect_no isn't unit length.

Definition at line 2134 of file math_geom.c.

References copy_v3_v3(), cross_v3_v3v3(), len_squared_v3(), madd_v3_v3fl(), mul_v3_fl(), and mul_v3_v3fl().

Referenced by camera_frame_fit_calc_from_data(), dist_squared_to_projected_aabb_precalc(), ED_view3d_win_to_3d_on_plane_with_fallback(), M_Geometry_intersect_plane_plane(), and UNUSED_FUNCTION().

◆ isect_planes_v3_fn()

bool isect_planes_v3_fn ( const float  planes[][4],
int  planes_len,
float  eps_coplanar,
float  eps_isect,
void(*)(const float co[3], int i, int j, int k, void *user_data callback_fn,
void user_data 
)

Intersect all planes, calling callback_fn for each point that intersects 3 of the planes that isn't outside any of the other planes.

This can be thought of as calculating a convex-hull from an array of planes.

Parameters
eps_coplanarEpsilon for testing if two planes are aligned (co-planar).
eps_isectEpsilon for testing of a point is behind any of the planes.
Warning
As complexity is a little under O(N^3), this is only suitable for small arrays.
Note
This function could be optimized by some spatial structure.

Definition at line 2168 of file math_geom.c.

References cross_v3_v3v3(), dot_v3v3(), ELEM, fabsf, len_squared_v3(), and user_data.

Referenced by ED_view3d_clipping_clamp_minmax(), and M_Geometry_points_in_planes().

◆ isect_point_planes_v3()

bool isect_point_planes_v3 ( float(*)  planes[4],
int  totplane,
const float  p[3] 
)

Check if a point is behind all planes.

Definition at line 2054 of file math_geom.c.

References plane_point_side_v3().

Referenced by is_effected(), and sculpt_gesture_is_vertex_effected().

◆ isect_point_planes_v3_negated()

bool isect_point_planes_v3_negated ( const float(*)  planes[4],
int  totplane,
const float  p[3] 
)

Check if a point is in front all planes. Same as isect_point_planes_v3 but with planes facing the opposite direction.

Definition at line 2067 of file math_geom.c.

References plane_point_side_v3().

Referenced by test_projected_vert_dist().

◆ isect_point_poly_v2()

bool isect_point_poly_v2 ( const float  pt[2],
const float  verts[][2],
const unsigned int  nr,
const bool   UNUSEDuse_holes 
)

Definition at line 1459 of file math_geom.c.

References verts.

◆ isect_point_poly_v2_int()

bool isect_point_poly_v2_int ( const int  pt[2],
const int  verts[][2],
const unsigned int  nr,
const bool   UNUSEDuse_holes 
)

Definition at line 1478 of file math_geom.c.

References verts.

◆ isect_point_quad_v2()

int isect_point_quad_v2 ( const float  p[2],
const float  v1[2],
const float  v2[2],
const float  v3[2],
const float  v4[2] 
)

◆ isect_point_tri_prism_v3()

bool isect_point_tri_prism_v3 ( const float  p[3],
const float  v1[3],
const float  v2[3],
const float  v3[3] 
)

◆ isect_point_tri_v2()

int isect_point_tri_v2 ( const float  pt[2],
const float  v1[2],
const float  v2[2],
const float  v3[2] 
)

◆ isect_point_tri_v2_cw()

bool isect_point_tri_v2_cw ( const float  pt[2],
const float  v1[2],
const float  v2[2],
const float  v3[2] 
)

Only single direction.

Definition at line 1500 of file math_geom.c.

References line_point_side_v2(), v1, and v2.

Referenced by bm_loop_collapse_is_degenerate(), and maskrasterize_layer_isect().

◆ isect_point_tri_v2_int()

int isect_point_tri_v2_int ( int  x1,
int  y1,
int  x2,
int  y2,
int  a,
int  b 
)
x1,y2
| \
| \ .(a,b)
| \
x1,y1-- x2,y1

Definition at line 3309 of file math_geom.c.

References Freestyle::a, usdtokens::b(), float(), isect_point_tri_v2(), v1, v2, x2, and y1.

◆ isect_point_tri_v3()

bool isect_point_tri_v3 ( const float  p[3],
const float  v1[3],
const float  v2[3],
const float  v3[3],
float  r_isect_co[3] 
)
Parameters
r_isect_coThe point p projected onto the triangle.
Returns
True when p is inside the triangle.
Note
Its up to the caller to check the distance between p and r_vi against an error margin.

Definition at line 3397 of file math_geom.c.

References BLI_assert, closest_to_plane_v3(), cross_tri_v3(), isect_point_tri_prism_v3(), len_squared_v3(), plane_from_point_normal_v3(), v1, and v2.

Referenced by bm_isect_tri_tri(), and M_Geometry_intersect_point_tri().

◆ isect_ray_aabb_v3()

bool isect_ray_aabb_v3 ( const struct IsectRayAABB_Precalc data,
const float  bb_min[3],
const float  bb_max[3],
float tmin_out 
)

Definition at line 3072 of file math_geom.c.

References copy_v3_v3(), and data.

Referenced by BKE_pbvh_raycast_project_ray_root(), and ray_aabb_intersect().

◆ isect_ray_aabb_v3_precalc()

void isect_ray_aabb_v3_precalc ( struct IsectRayAABB_Precalc data,
const float  ray_origin[3],
const float  ray_direction[3] 
)

Definition at line 3057 of file math_geom.c.

References copy_v3_v3(), and data.

Referenced by BKE_pbvh_raycast(), and BKE_pbvh_raycast_project_ray_root().

◆ isect_ray_aabb_v3_simple()

bool isect_ray_aabb_v3_simple ( const float  orig[3],
const float  dir[3],
const float  bb_min[3],
const float  bb_max[3],
float tmin,
float tmax 
)

Test a bounding box (AABB) for ray intersection. Assumes the ray is already local to the boundbox space.

Note
direction should be normalized if you intend to use the tmin or tmax distance results!

Definition at line 3124 of file math_geom.c.

References double(), float(), and t.

Referenced by raycastEditMesh(), and raycastMesh().

◆ isect_ray_line_v3()

bool isect_ray_line_v3 ( const float  ray_origin[3],
const float  ray_direction[3],
const float  v0[3],
const float  v1[3],
float r_lambda 
)

◆ isect_ray_plane_v3()

bool isect_ray_plane_v3 ( const float  ray_origin[3],
const float  ray_direction[3],
const float  plane[4],
float r_lambda,
bool  clip 
)

◆ isect_ray_ray_epsilon_v3()

bool isect_ray_ray_epsilon_v3 ( const float  ray_origin_a[3],
const float  ray_direction_a[3],
const float  ray_origin_b[3],
const float  ray_direction_b[3],
float  epsilon,
float r_lambda_a,
float r_lambda_b 
)

Check if two rays are not parallel and returns a factor that indicates the distance from ray_origin_b to the closest point on ray-a to ray-b.

Note
Neither directions need to be normalized.

Definition at line 2996 of file math_geom.c.

References BLI_assert, Freestyle::c, cross_v3_v3v3(), dot_v3v3(), blender::robust_pred::epsilon, len_squared_v3(), NULL, sub_v3_v3v3(), t, and UNLIKELY.

Referenced by bm_edgexedge_isect_cb(), and isect_ray_ray_v3().

◆ isect_ray_ray_v3()

bool isect_ray_ray_v3 ( const float  ray_origin_a[3],
const float  ray_direction_a[3],
const float  ray_origin_b[3],
const float  ray_direction_b[3],
float r_lambda_a,
float r_lambda_b 
)

◆ isect_ray_seg_v2()

bool isect_ray_seg_v2 ( const float  ray_origin[2],
const float  ray_direction[2],
const float  v0[2],
const float  v1[2],
float r_lambda,
float r_u 
)

Definition at line 1982 of file math_geom.c.

References cross_v2v2(), dot_v2v2(), sub_v2_v2v2(), t, v, and v1.

Referenced by bvhtree_test_edges_isect_2d_ray_cb(), and test_edges_isect_2d_ray().

◆ isect_ray_tri_epsilon_v3()

bool isect_ray_tri_epsilon_v3 ( const float  ray_origin[3],
const float  ray_direction[3],
const float  v0[3],
const float  v1[3],
const float  v2[3],
float r_lambda,
float  r_uv[2],
const float  epsilon 
)

◆ isect_ray_tri_v3()

bool isect_ray_tri_v3 ( const float  ray_origin[3],
const float  ray_direction[3],
const float  v0[3],
const float  v1[3],
const float  v2[3],
float r_lambda,
float  r_uv[2] 
)

◆ isect_ray_tri_watertight_v3()

bool isect_ray_tri_watertight_v3 ( const float  ray_origin[3],
const struct IsectRayPrecalc isect_precalc,
const float  v0[3],
const float  v1[3],
const float  v2[3],
float r_lambda,
float  r_uv[2] 
)

◆ isect_ray_tri_watertight_v3_precalc()

void isect_ray_tri_watertight_v3_precalc ( struct IsectRayPrecalc isect_precalc,
const float  ray_direction[3] 
)

◆ isect_ray_tri_watertight_v3_simple()

bool isect_ray_tri_watertight_v3_simple ( const float  ray_origin[3],
const float  ray_direction[3],
const float  v0[3],
const float  v1[3],
const float  v2[3],
float r_lambda,
float  r_uv[2] 
)

Slower version which calculates IsectRayPrecalc each time.

Definition at line 1886 of file math_geom.c.

References isect_ray_tri_watertight_v3(), isect_ray_tri_watertight_v3_precalc(), v1, and v2.

◆ isect_seg_seg_v2()

int isect_seg_seg_v2 ( const float  v1[2],
const float  v2[2],
const float  v3[2],
const float  v4[2] 
)

◆ isect_seg_seg_v2_int()

int isect_seg_seg_v2_int ( const int  v1[2],
const int  v2[2],
const int  v3[2],
const int  v4[2] 
)

Intersect Line-Line, integer.

Definition at line 1063 of file math_geom.c.

References float(), ISECT_LINE_LINE_COLINEAR, ISECT_LINE_LINE_CROSS, ISECT_LINE_LINE_EXACT, ISECT_LINE_LINE_NONE, v1, and v2.

Referenced by BLI_lasso_is_edge_inside().

◆ isect_seg_seg_v2_lambda_mu_db()

int isect_seg_seg_v2_lambda_mu_db ( const double  v1[2],
const double  v2[2],
const double  v3[2],
const double  v4[2],
double r_lambda,
double r_mu 
)

If intersection == ISECT_LINE_LINE_CROSS or ISECT_LINE_LINE_NONE:

pt = v1 + lambda * (v2 - v1) = v3 + mu * (v4 - v3)
Returns
intersection type:
  • ISECT_LINE_LINE_COLINEAR: collinear.
  • ISECT_LINE_LINE_EXACT: intersection at an endpoint of either.
  • ISECT_LINE_LINE_CROSS: interaction, not at an endpoint.
  • ISECT_LINE_LINE_NONE: no intersection. Also returns lambda and mu in r_lambda and r_mu.

Definition at line 1315 of file math_geom.c.

References fabs(), ISECT_LINE_LINE_COLINEAR, ISECT_LINE_LINE_CROSS, ISECT_LINE_LINE_EXACT, ISECT_LINE_LINE_NONE, v1, and v2.

◆ isect_seg_seg_v2_point()

int isect_seg_seg_v2_point ( const float  v0[2],
const float  v1[2],
const float  v2[2],
const float  v3[2],
float  r_vi[2] 
)

◆ isect_seg_seg_v2_point_ex()

int isect_seg_seg_v2_point_ex ( const float  v0[2],
const float  v1[2],
const float  v2[2],
const float  v3[2],
float  endpoint_bias,
float  vi[2] 
)

Get intersection point of two 2D segments.

Parameters
endpoint_biasBias to use when testing for end-point overlap. A positive value considers intersections that extend past the endpoints, negative values contract the endpoints. Note the bias is applied to a 0-1 factor, not scaled to the length of segments.
Returns
intersection type:
  • -1: collinear.
  • 1: intersection.
  • 0: no intersection.

Definition at line 1195 of file math_geom.c.

References copy_v2_v2(), cross_v2v2(), dot_v2v2(), eps, equals_v2v2(), len_squared_v2v2(), line_point_factor_v2(), madd_v2_v2v2fl(), max_ff(), min_ff(), square_f(), sub_v2_v2v2(), SWAP, v, v1, and v2.

Referenced by edge_isect_verts_point_2d(), isect_seg_seg_v2_point(), knife_find_line_hits(), and overlap_tri_tri_uv_test().

◆ isect_seg_seg_v2_simple()

bool isect_seg_seg_v2_simple ( const float  v1[2],
const float  v2[2],
const float  v3[2],
const float  v4[2] 
)

Definition at line 1303 of file math_geom.c.

References CCW, v1, and v2.

Referenced by closest_seg_seg_v2(), dist_seg_seg_v2(), feather_bucket_check_intersect(), and uv_image_outset().

◆ isect_seg_seg_v3()

void isect_seg_seg_v3 ( const float  a0[3],
const float  a1[3],
const float  b0[3],
const float  b1[3],
float  r_a[3],
float  r_b[3] 
)

Returns a point on each segment that is closest to the other.

Definition at line 1130 of file math_geom.c.

References Freestyle::c, CLAMP, cross_v3_v3v3(), dot_v3v3(), len_squared_v3(), madd_v3_v3v3fl(), and sub_v3_v3v3().

Referenced by compute_collision_point_edge_tri(), and compute_collision_point_tri_tri().

◆ isect_sweeping_sphere_tri_v3()

bool isect_sweeping_sphere_tri_v3 ( const float  p1[3],
const float  p2[3],
const float  radius,
const float  v0[3],
const float  v1[3],
const float  v2[3],
float r_lambda,
float  ipoint[3] 
)

◆ isect_tri_tri_impl_ccw_v2()

static int isect_tri_tri_impl_ccw_v2 ( const float  t_a0[2],
const float  t_a1[2],
const float  t_a2[2],
const float  t_b0[2],
const float  t_b1[2],
const float  t_b2[2] 
)
static

◆ isect_tri_tri_v2()

bool isect_tri_tri_v2 ( const float  t_a0[2],
const float  t_a1[2],
const float  t_a2[2],
const float  t_b0[2],
const float  t_b1[2],
const float  t_b2[2] 
)

Definition at line 2541 of file math_geom.c.

References isect_tri_tri_impl_ccw_v2(), and line_point_side_v2().

Referenced by M_Geometry_intersect_tri_tri_2d().

◆ isect_tri_tri_v2_impl_edge()

static bool isect_tri_tri_v2_impl_edge ( const float  t_a0[2],
const float  t_a1[2],
const float  t_a2[2],
const float  t_b0[2],
const float  t_b1[2],
const float  t_b2[2] 
)
static

Definition at line 2459 of file math_geom.c.

References line_point_side_v2(), and UNUSED_VARS.

Referenced by isect_tri_tri_impl_ccw_v2().

◆ isect_tri_tri_v2_impl_vert()

static bool isect_tri_tri_v2_impl_vert ( const float  t_a0[2],
const float  t_a1[2],
const float  t_a2[2],
const float  t_b0[2],
const float  t_b1[2],
const float  t_b2[2] 
)
static

Definition at line 2396 of file math_geom.c.

References line_point_side_v2().

Referenced by isect_tri_tri_impl_ccw_v2().

◆ isect_tri_tri_v3()

bool isect_tri_tri_v3 ( const float  t_a0[3],
const float  t_a1[3],
const float  t_a2[3],
const float  t_b0[3],
const float  t_b1[3],
const float  t_b2[3],
float  r_i1[3],
float  r_i2[3] 
)

◆ isect_tri_tri_v3_ex()

bool isect_tri_tri_v3_ex ( const float  tri_a[3][3],
const float  tri_b[3][3],
float  r_i1[3],
float  r_i2[3],
int *  r_tri_a_edge_isect_count 
)

Intersect two triangles.

Parameters
r_i1,r_i2Retrieve the overlapping edge between the 2 triangles.
r_tri_a_edge_isect_countIndicates how many edges in the first triangle are intersected.
Returns
true when the triangles intersect.
Note
If it exists, r_i1 will be a point on the edge of the 1st triangle.
intersections between coplanar triangles are currently undetected.

Definition at line 2230 of file math_geom.c.

References copy_v3_v3(), cross_v3_v3v3_db(), dot_v3db_v3fl(), float(), interp_v3_v3v3(), max, min, sub_v3db_v3fl_v3fl(), and SWAP.

Referenced by compute_collision_point_tri_tri(), and isect_tri_tri_v3().

◆ limit_dist_v3()

void limit_dist_v3 ( float  v1[3],
float  v2[3],
float  dist 
)

Ensure the distance between these points is no greater than 'dist'. If it is, scale them both into the center.

Definition at line 3292 of file math_geom.c.

References copy_v3_v3(), interp_v3_v3v3(), len_v3v3(), v1, and v2.

◆ line_plane_factor_v3()

float line_plane_factor_v3 ( const float  plane_co[3],
const float  plane_no[3],
const float  l1[3],
const float  l2[3] 
)
Note
isect_line_plane_v3() shares logic.

Definition at line 3279 of file math_geom.c.

References blender::math::dot(), dot_v3v3(), and sub_v3_v3v3().

Referenced by apply_stroke_envelope().

◆ line_point_factor_v2()

float line_point_factor_v2 ( const float  p[2],
const float  l1[2],
const float  l2[2] 
)

◆ line_point_factor_v2_ex()

float line_point_factor_v2_ex ( const float  p[2],
const float  l1[2],
const float  l2[2],
const float  epsilon,
const float  fallback 
)

◆ line_point_factor_v3()

float line_point_factor_v3 ( const float  p[3],
const float  l1[3],
const float  l2[3] 
)

◆ line_point_factor_v3_ex()

float line_point_factor_v3_ex ( const float  p[3],
const float  l1[3],
const float  l2[3],
float  epsilon,
float  fallback 
)

A simplified version of closest_to_line_v3 we only need to return the lambda

Parameters
epsilonavoid approaching divide-by-zero. Passing a zero will just check for nonzero division.

Definition at line 3239 of file math_geom.c.

References blender::math::dot(), dot_v3v3(), blender::robust_pred::epsilon, len_squared_v3(), and sub_v3_v3v3().

Referenced by line_point_factor_v3().

◆ lookat_m4()

void lookat_m4 ( float  mat[4][4],
float  vx,
float  vy,
float  vz,
float  px,
float  py,
float  pz,
float  twist 
)

Definition at line 4782 of file math_geom.c.

References axis_angle_to_mat4_single(), i_multmatrix(), sqrtf, translate_m4(), and unit_m4().

◆ map_to_plane_axis_angle_v2_v3v3fl()

void map_to_plane_axis_angle_v2_v3v3fl ( float  r_co[2],
const float  co[3],
const float  axis[3],
const float  angle 
)

Definition at line 4963 of file math_geom.c.

References angle(), copy_v2_v2(), and rotate_normalized_v3_v3v3fl().

Referenced by computeBindWeights(), and map_to_plane_v2_v3v3().

◆ map_to_plane_v2_v3v3()

void map_to_plane_v2_v3v3 ( float  r_co[2],
const float  co[3],
const float  no[3] 
)

◆ map_to_sphere()

void map_to_sphere ( float r_u,
float r_v,
const float  x,
const float  y,
const float  z 
)

◆ map_to_tube()

void map_to_tube ( float r_u,
float r_v,
const float  x,
const float  y,
const float  z 
)

Definition at line 4917 of file math_geom.c.

References atan2f, float(), len, M_PI, sqrtf, x, y, and z.

Referenced by do_2d_mapping(), svm_node_tex_image(), and uv_cylinder_project().

◆ mean_value_half_tan_v2_db()

static double mean_value_half_tan_v2_db ( const struct Double2_Len d_curr,
const struct Double2_Len d_next 
)
static

Mean value weights - same as mean_value_half_tan_v3 but for 2D vectors.

Note
When interpolating a 2D polygon, a point can be considered "outside" the polygon's bounds. Thus, when the point is very distant and the vectors have relatively close values, the precision problems are evident since they do not indicate a point "inside" the polygon. To resolve this, doubles are used.

Definition at line 4058 of file math_geom.c.

References blender::compositor::area(), cross_v2v2_db(), Double2_Len::dir, blender::math::dot(), dot_v2v2_db(), CCL_NAMESPACE_BEGIN::isfinite(), Double2_Len::len, len, LIKELY, and result.

Referenced by interp_weights_poly_v2().

◆ mean_value_half_tan_v3()

static float mean_value_half_tan_v3 ( const struct Float3_Len d_curr,
const struct Float3_Len d_next 
)
static

◆ normal_poly_v3()

float normal_poly_v3 ( float  n[3],
const float  verts[][3],
unsigned int  nr 
)

Computes the normal of a planar polygon See Graphics Gems for computing newell normal.

Definition at line 71 of file math_geom.c.

References cross_poly_v3(), normalize_v3(), and verts.

Referenced by computeBindWeights(), deformVert(), M_Geometry_normal(), and sculpt_boundary_twist_data_init().

◆ normal_quad_v3()

float normal_quad_v3 ( float  n[3],
const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3] 
)

◆ normal_tri_v3()

float normal_tri_v3 ( float  n[3],
const float  v1[3],
const float  v2[3],
const float  v3[3] 
)

Definition at line 33 of file math_geom.c.

References normalize_v3(), v1, and v2.

Referenced by bindVert(), BKE_mesh_calc_normals_looptri(), BKE_mesh_calc_poly_normal(), BKE_mesh_calc_poly_normal_coords(), bm_edge_calc_rotate_beauty__angle(), bm_edge_collapse_is_degenerate_flip(), BM_face_calc_normal(), BM_face_calc_normal_vcos(), bm_isect_tri_tri(), BM_verts_calc_normal_from_cloud_ex(), bmesh_calc_tessellation_for_face_impl(), bmo_edgenet_prepare_exec(), bvh_callback(), C_BVHTree_FromPolygons(), calc_area_normal_and_center_task_cb(), cloth_bend_poly_dir(), cloth_brush_collision_cb(), blender::nodes::node_geo_distribute_points_on_faces_cc::compute_attribute_outputs(), compute_collision_point_edge_tri(), compute_collision_point_tri_tri(), blender::nodes::node_geo_curve_primitive_arc_cc::create_arc_curve_from_points(), dm_ts_GetNormal(), dynamic_paint_paint_mesh_cell_point_cb_ex(), ED_view3d_clipping_calc_from_boundbox(), editmesh_looptri_nearest_point(), editmesh_looptri_spherecast(), getTransformOrientation_ex(), harmonic_ray_callback(), heat_calc_vnormals(), initLaplacianMatrix(), Freestyle::BlenderFileLoader::insertShapeNode(), interp_weights_tri_v3(), knife_ray_intersect_face(), lineart_load_tri_task(), make_face(), mesh_faces_nearest_point(), mesh_faces_spherecast(), mesh_looptri_nearest_point(), mesh_looptri_spherecast(), pbvh_bmesh_node_raycast(), pbvh_faces_node_raycast(), poly_norm(), project_paint_uvpixel_mask(), psys_interpolate_face(), py_bvhtree_nearest_point_range_cb(), quad_calc_error(), rotateDifferentialCoordinates(), blender::ed::sculpt_paint::AddOperationExecutor::sample_spherical(), blender::bke::mesh_surface_sample::sample_surface_points_spherical(), sculpt_gesture_line_calculate_plane_points(), sculpt_gesture_line_plane_from_tri(), blender::draw::statvis_calc_distort(), blender::draw::statvis_calc_thickness(), transform_point_by_tri_v3(), tri_to_quat(), tri_to_quat_ex(), triatomat(), view3d_boxview_clip(), and voxel_size_edit_invoke().

◆ orthographic_m4()

void orthographic_m4 ( float  mat[4][4],
float  left,
float  right,
float  bottom,
float  top,
float  nearClip,
float  farClip 
)

◆ perspective_m4()

void perspective_m4 ( float  mat[4][4],
float  left,
float  right,
float  bottom,
float  top,
float  nearClip,
float  farClip 
)

◆ perspective_m4_fov()

void perspective_m4_fov ( float  mat[4][4],
const float  angle_left,
const float  angle_right,
const float  angle_up,
const float  angle_down,
const float  nearClip,
const float  farClip 
)

Definition at line 4568 of file math_geom.c.

References perspective_m4(), and tanf.

Referenced by wm_xr_draw_matrices_create().

◆ plane_from_point_normal_v3()

void plane_from_point_normal_v3 ( float  r_plane[4],
const float  plane_co[3],
const float  plane_no[3] 
)

Calculate a plane from a point and a direction,

Note
point_no isn't required to be normalized.

Definition at line 209 of file math_geom.c.

References copy_v3_v3(), and dot_v3v3().

Referenced by BKE_mesh_mirror_bisect_on_mirror_plane_for_modifier(), bmo_bisect_plane_exec(), bmo_planar_faces_exec(), build_boundary_terminal_edge(), calc_clay_surface_task_cb(), calc_initial_placement_point_from_view(), camera_frame_fit_calc_from_data(), cloth_brush_solve_collision(), blender::nodes::node_geo_curve_primitive_arc_cc::create_arc_curve_from_points(), blender::nodes::node_geo_curve_primitive_circle_cc::create_point_circle_curve(), dial_ghostarc_get_angles(), dist_signed_squared_to_corner_v3v3v3(), do_clay_brush_task_cb_ex(), do_clay_strips_brush_task_cb_ex(), do_clay_thumb_brush_task_cb_ex(), do_cloth_brush_apply_forces_task_cb_ex(), do_fill_brush_task_cb_ex(), do_flatten_brush_task_cb_ex(), do_scrape_brush_task_cb_ex(), draw_primitive_view_impl(), ED_view3d_win_to_3d(), face_to_plane(), getVerticalAndHorizontalChange(), gizmo_arrow_modal(), gizmo_mesh_spin_redo_setup(), gizmo_window_project_2d(), gpencil_depth_plane(), gpencil_sculpt_compute_lock_axis(), interp_slerp_co_no_v3(), isect_point_tri_v3(), knife_find_line_hits(), knife_ray_intersect_face(), knife_snap_angle_relative(), M_Geometry_distance_point_to_plane(), M_Geometry_intersect_plane_plane(), modifyMesh(), offset_meet(), sculpt_boundary_displacement_from_grab_delta_get(), SCULPT_brush_test_init_with_falloff_shape(), SCULPT_do_multiplane_scrape_brush(), sculpt_gesture_line_plane_from_tri(), sculpt_gesture_trim_calculate_depth(), sculpt_gesture_trim_geometry_generate(), sculpt_pose_get_scale_from_grab_delta(), SCULPT_relax_vertex(), snap_to_pipe_profile(), transform_constraint_snap_axis_to_face(), transform_snap_context_project_view3d_mixed_impl(), UNUSED_FUNCTION(), v3d_cursor_snap_update(), view3d_interactive_add_begin(), and view3d_interactive_add_modal().

◆ plane_to_point_vector_v3()

void plane_to_point_vector_v3 ( const float  plane[4],
float  r_plane_co[3],
float  r_plane_no[3] 
)

Get a point and a direction from a plane.

Definition at line 215 of file math_geom.c.

References copy_v3_v3(), len_squared_v3(), and mul_v3_v3fl().

◆ plane_to_point_vector_v3_normalized()

void plane_to_point_vector_v3_normalized ( const float  plane[4],
float  r_plane_co[3],
float  r_plane_no[3] 
)

Version of plane_to_point_vector_v3 that gets a unit length vector.

Definition at line 221 of file math_geom.c.

References blender::math::length(), mul_v3_v3fl(), and normalize_v3_v3().

◆ planes_from_projmat()

void planes_from_projmat ( const float  mat[4][4],
float  left[4],
float  right[4],
float  bottom[4],
float  top[4],
float  near[4],
float  far[4] 
)

Frustum planes extraction from a projection matrix (homogeneous 4d vector representations of planes).

plane parameters can be NULL if you do not need them.

Definition at line 4615 of file math_geom.c.

References bottom, left, right, and top.

Referenced by BLI_bvhtree_find_nearest_projected(), camera_frame_fit_data_init(), content_planes_from_clip_flag(), draw_frustum_culling_planes_calc(), knifetool_raycast_planes(), and transform_snap_context_project_view3d_mixed_impl().

◆ point_in_slice()

static bool point_in_slice ( const float  p[3],
const float  v1[3],
const float  l1[3],
const float  l2[3] 
)
static

Definition at line 3329 of file math_geom.c.

References closest_to_line_v3(), dot_v3v3(), sub_v3_v3v3(), and v1.

Referenced by isect_point_tri_prism_v3().

◆ point_in_slice_as()

static bool point_in_slice_as ( const float  p[3],
const float  origin[3],
const float  normal[3] 
)
static

Definition at line 3360 of file math_geom.c.

References dot_v3v3(), normal, and sub_v3_v3v3().

Referenced by point_in_slice_seg().

◆ point_in_slice_seg()

bool point_in_slice_seg ( float  p[3],
float  l1[3],
float  l2[3] 
)

◆ polarview_m4()

void polarview_m4 ( float  mat[4][4],
float  dist,
float  azimuth,
float  incidence,
float  twist 
)

Definition at line 4772 of file math_geom.c.

References rotate_m4(), translate_m4(), and unit_m4().

◆ projmat_dimensions()

void projmat_dimensions ( const float  winmat[4][4],
float r_left,
float r_right,
float r_bottom,
float r_top,
float r_near,
float r_far 
)

Definition at line 4668 of file math_geom.c.

Referenced by draw_frustum_boundbox_calc().

◆ projmat_dimensions_db()

void projmat_dimensions_db ( const float  winmat_fl[4][4],
double r_left,
double r_right,
double r_bottom,
double r_top,
double r_near,
double r_far 
)

Definition at line 4696 of file math_geom.c.

References copy_m4d_m4().

◆ projmat_from_subregion()

void projmat_from_subregion ( const float  projmat[4][4],
const int  win_size[2],
int  x_min,
int  x_max,
int  y_min,
int  y_max,
float  r_projmat[4][4] 
)

Creates a projection matrix for a small region of the viewport.

Parameters
projmatProjection Matrix.
win_sizeViewport Size.
x_min,x_max,y_min,y_maxCoordinates of the subregion.
Returns
r_projmat: Resulting Projection Matrix.

Definition at line 4727 of file math_geom.c.

References copy_m4_m4(), float(), rect_height(), and rect_width().

Referenced by select_engine_init().

◆ ray_point_factor_v3()

float ray_point_factor_v3 ( const float  p[3],
const float  ray_origin[3],
const float  ray_direction[3] 
)

Definition at line 3232 of file math_geom.c.

References ray_point_factor_v3_ex().

Referenced by ED_view3d_win_to_3d().

◆ ray_point_factor_v3_ex()

float ray_point_factor_v3_ex ( const float  p[3],
const float  ray_origin[3],
const float  ray_direction[3],
const float  epsilon,
const float  fallback 
)

◆ resolve_quad_u_v2()

float resolve_quad_u_v2 ( const float  st[2],
const float  st0[2],
const float  st1[2],
const float  st2[2],
const float  st3[2] 
)

A version of resolve_quad_uv_v2 that only calculates the 'u'.

Definition at line 4441 of file math_geom.c.

References Freestyle::a, usdtokens::b(), double(), IS_ZERO, sqrt(), and usdtokens::st().

Referenced by project_paint_face_init().

◆ resolve_quad_uv_v2()

void resolve_quad_uv_v2 ( float  r_uv[2],
const float  st[2],
const float  st0[2],
const float  st1[2],
const float  st2[2],
const float  st3[2] 
)

Bilinear reverse.

Definition at line 4341 of file math_geom.c.

References NULL, resolve_quad_uv_v2_deriv(), and usdtokens::st().

Referenced by apply_heights_callback(), apply_tangmat_callback(), and quad_co().

◆ resolve_quad_uv_v2_deriv()

void resolve_quad_uv_v2_deriv ( float  r_uv[2],
float  r_deriv[2][2],
const float  st[2],
const float  st0[2],
const float  st1[2],
const float  st2[2],
const float  st3[2] 
)

Bilinear reverse with derivatives.

Definition at line 4351 of file math_geom.c.

References Freestyle::a, usdtokens::b(), double(), fabs(), float(), interp_v2_v2v2(), IS_ZERO, sqrt(), usdtokens::st(), sub_v2_v2v2(), t, and zero_v2().

Referenced by resolve_quad_uv_v2().

◆ resolve_tri_uv_v2()

void resolve_tri_uv_v2 ( float  r_uv[2],
const float  st[2],
const float  st0[2],
const float  st1[2],
const float  st2[2] 
)

Barycentric reverse

Compute coordinates (u, v) for point st with respect to triangle (st0, st1, st2)

Note
same basic result as barycentric_weights_v2, see its comment for details.

Definition at line 4288 of file math_geom.c.

References Freestyle::a, usdtokens::b(), Freestyle::c, float(), IS_ZERO, usdtokens::st(), x, and zero_v2().

Referenced by apply_heights_callback(), apply_tangmat_callback(), and flush_pixel().

◆ resolve_tri_uv_v3()

void resolve_tri_uv_v3 ( float  r_uv[2],
const float  st[3],
const float  st0[3],
const float  st1[3],
const float  st2[3] 
)

Barycentric reverse 3d

Compute coordinates (u, v) for point st with respect to triangle (st0, st1, st2)

Definition at line 4310 of file math_geom.c.

References dot_v3v3(), float(), IS_ZERO, usdtokens::st(), sub_v3_v3v3(), v1, v2, w(), and zero_v2().

◆ tangent_from_uv_v3()

void tangent_from_uv_v3 ( const float  uv1[2],
const float  uv2[2],
const float  uv3[2],
const float  co1[3],
const float  co2[3],
const float  co3[3],
const float  n[3],
float  r_tang[3] 
)

Definition at line 5095 of file math_geom.c.

References cross_v3_v3v3(), dot_v3v3(), negate_v3(), sub_v3_v3v3(), and zero_v3().

◆ transform_point_by_seg_v3()

void transform_point_by_seg_v3 ( float  p_dst[3],
const float  p_src[3],
const float  l_dst_p1[3],
const float  l_dst_p2[3],
const float  l_src_p1[3],
const float  l_src_p2[3] 
)

Simply re-interpolates, assumes p_src is between l_src_p1-l_src_p2

Definition at line 3906 of file math_geom.c.

References interp_v3_v3v3(), line_point_factor_v3(), and t.

Referenced by knife_find_line_hits().

◆ transform_point_by_tri_v3()

void transform_point_by_tri_v3 ( float  pt_tar[3],
float const  pt_src[3],
const float  tri_tar_p1[3],
const float  tri_tar_p2[3],
const float  tri_tar_p3[3],
const float  tri_src_p1[3],
const float  tri_src_p2[3],
const float  tri_src_p3[3] 
)

Given 2 triangles in 3D space, and a point in relation to the first triangle. calculate the location of a point in relation to the second triangle. Useful for finding relative positions with geometry.

Definition at line 3862 of file math_geom.c.

References area_tri_v2(), area_tri_v3(), axis_dominant_v3_to_m3(), barycentric_weights_v2(), interp_v3_v3v3v3(), madd_v3_v3v3fl(), mul_v3_m3v3(), normal_tri_v3(), and sqrtf.

Referenced by BKE_mesh_calc_relative_deform(), bm_edgering_pair_interpolate(), bm_grid_fill_array(), and M_Geometry_barycentric_transform().

◆ tri_signed_area()

static float tri_signed_area ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const int  i,
const int  j 
)
static

Definition at line 3562 of file math_geom.c.

References v1, and v2.

Referenced by barycentric_weights().

◆ vcloud_estimate_transform_v3()

void vcloud_estimate_transform_v3 ( int  list_size,
const float(*)  pos[3],
const float weight,
const float(*)  rpos[3],
const float rweight,
float  lloc[3],
float  rloc[3],
float  lrot[3][3],
float  lscale[3][3] 
)

Input:

Parameters
list_size4 lists as pointer to array[list_size]
poscurrent pos array of 'new' positions
weightcurrent weight array of 'new'weights (may be NULL pointer if you have no weights)
rposReference rpos array of 'old' positions
rweightReference rweight array of 'old'weights (may be NULL pointer if you have no weights).

Output:

Parameters
llocCenter of mass pos.
rlocCenter of mass rpos.
lrotRotation matrix.
lscaleScale matrix.

pointers may be NULL if not needed

Definition at line 5141 of file math_geom.c.

References Freestyle::a, add_m3_m3m3(), add_v3_v3(), copy_m3_m3(), copy_v3_v3(), determinant_m3_array(), eps, float(), invert_m3_m3(), len_v3(), mul_m3_fl(), mul_m3_m3m3(), mul_v3_fl(), pos, sub_v3_v3v3(), transpose_m3(), unit_m3(), v, zero_m3(), and zero_v3().

Referenced by SB_estimate_transform().

◆ vec_add_dir()

static void vec_add_dir ( float  r[3],
const float  v1[3],
const float  v2[3],
const float  fac 
)
static

Definition at line 5292 of file math_geom.c.

References r, v1, and v2.

Referenced by form_factor_visible_quad().

◆ volume_tetrahedron_signed_v3()

float volume_tetrahedron_signed_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3] 
)

The volume from a tetrahedron, normal pointing inside gives negative volume

Definition at line 243 of file math_geom.c.

References determinant_m3_array(), sub_v3_v3v3(), v1, and v2.

Referenced by BKE_mesh_calc_volume(), and compute_volume().

◆ volume_tetrahedron_v3()

float volume_tetrahedron_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3],
const float  v4[3] 
)

The volume from a tetrahedron, points can be in any order

Definition at line 231 of file math_geom.c.

References determinant_m3_array(), fabsf, sub_v3_v3v3(), v1, and v2.

Referenced by M_Geometry_volume_tetrahedron().

◆ volume_tri_tetrahedron_signed_v3()

float volume_tri_tetrahedron_signed_v3 ( const float  v1[3],
const float  v2[3],
const float  v3[3] 
)

Definition at line 263 of file math_geom.c.

References v1, v2, and volume_tri_tetrahedron_signed_v3_6x().

◆ volume_tri_tetrahedron_signed_v3_6x()

float volume_tri_tetrahedron_signed_v3_6x ( const float  v1[3],
const float  v2[3],
const float  v3[3] 
)

The volume from a triangle that is made into a tetrahedron. This uses a simplified formula where the tip of the tetrahedron is in the world origin. Using this method, the total volume of a closed triangle mesh can be calculated. Note that you need to divide the result by 6 to get the actual volume.

Definition at line 255 of file math_geom.c.

References cross_v3_v3v3(), dot_v3v3(), v1, and v2.

Referenced by cloth_calc_rest_volume(), mesh_calc_poly_volume_centroid(), mesh_calc_poly_volume_centroid_with_reference_center(), SIM_tri_tetra_volume_signed_6x(), and volume_tri_tetrahedron_signed_v3().

◆ window_translate_m4()

void window_translate_m4 ( float  winmat[4][4],
float  perspmat[4][4],
float  x,
float  y 
)

Translate a matrix created by orthographic_m4 or perspective_m4 in XY coords (used to jitter the view).

Definition at line 4587 of file math_geom.c.

References len_v3(), v1, v2, x, and y.

Referenced by EEVEE_temporal_sampling_matrices_calc(), and workbench_antialiasing_setup().