Blender  V3.3
Functions
blender::bke::curves::poly Namespace Reference

Functions

void calculate_tangents (Span< float3 > positions, bool is_cyclic, MutableSpan< float3 > tangents)
 
void calculate_normals_minimum (Span< float3 > tangents, bool cyclic, MutableSpan< float3 > normals)
 
void calculate_normals_z_up (Span< float3 > tangents, MutableSpan< float3 > normals)
 
static float3 direction_bisect (const float3 &prev, const float3 &middle, const float3 &next, bool &r_used_fallback)
 
static float3 calculate_next_normal (const float3 &last_normal, const float3 &last_tangent, const float3 &current_tangent)
 

Function Documentation

◆ calculate_next_normal()

static float3 blender::bke::curves::poly::calculate_next_normal ( const float3 last_normal,
const float3 last_tangent,
const float3 current_tangent 
)
static

Rotate the last normal in the same way the tangent has been rotated.

Definition at line 139 of file curve_poly.cc.

References angle(), angle_normalized_v3v3(), blender::math::cross(), blender::math::is_zero(), blender::math::normalize(), and blender::math::rotate_direction_around_axis().

Referenced by calculate_normals_minimum().

◆ calculate_normals_minimum()

void blender::bke::curves::poly::calculate_normals_minimum ( Span< float3 tangents,
bool  cyclic,
MutableSpan< float3 normals 
)

Calculate directions perpendicular to the tangent at every point by rotating an arbitrary starting vector by the same rotation of each tangent. If the curve is cyclic, propagate a correction through the entire to make sure the first and last normal align.

Definition at line 154 of file curve_poly.cc.

References angle(), angle_signed_on_axis_v3v3_v3(), BLI_assert, calculate_next_normal(), blender::robust_pred::epsilon, fabs(), M_PI, blender::math::normalize(), normals, blender::math::rotate_direction_around_axis(), and tangents.

◆ calculate_normals_z_up()

void blender::bke::curves::poly::calculate_normals_z_up ( Span< float3 tangents,
MutableSpan< float3 normals 
)

Calculate a vector perpendicular to every tangent on the X-Y plane (unless the tangent is vertical, in that case use the X direction).

Definition at line 119 of file curve_poly.cc.

References blender::math::abs(), BLI_assert, blender::robust_pred::epsilon, blender::math::normalize(), normals, and tangents.

◆ calculate_tangents()

void blender::bke::curves::poly::calculate_tangents ( Span< float3 positions,
bool  is_cyclic,
MutableSpan< float3 tangents 
)

Calculate the direction at every point, defined as the normalized average of the two neighboring segments (and if non-cyclic, the direction of the first and last segments). This is different than evaluating the derivative of the basis functions for curve types like NURBS, Bezier, or Catmull Rom, though the results may be similar.

Definition at line 41 of file curve_poly.cc.

References blender::math::almost_equal_relative(), BLI_assert, direction_bisect(), blender::robust_pred::epsilon, is_cyclic(), blender::math::is_zero(), blender::math::normalize(), positions, and tangents.

◆ direction_bisect()

static float3 blender::bke::curves::poly::direction_bisect ( const float3 prev,
const float3 middle,
const float3 next,
bool r_used_fallback 
)
static