Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions includes/rtm/vector4d.h
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,24 @@ namespace rtm
return vector_length3_as_scalar(difference);
}

//////////////////////////////////////////////////////////////////////////
// Returns the squared distance between two 3D points.
//////////////////////////////////////////////////////////////////////////
RTM_DISABLE_SECURITY_COOKIE_CHECK RTM_FORCE_INLINE rtm_impl::vector4d_vector_dot3 RTM_SIMD_CALL vector_distance_squared3(vector4d_arg0 lhs, vector4d_arg1 rhs) RTM_NO_EXCEPT
{
const vector4d difference = vector_sub(lhs, rhs);
return rtm_impl::vector4d_vector_dot3{ difference, difference };
}

//////////////////////////////////////////////////////////////////////////
// Returns the squared distance between two 3D points.
//////////////////////////////////////////////////////////////////////////
RTM_DISABLE_SECURITY_COOKIE_CHECK RTM_FORCE_INLINE scalard RTM_SIMD_CALL vector_distance_squared3_as_scalar(vector4d_arg0 lhs, vector4d_arg1 rhs) RTM_NO_EXCEPT
{
const vector4d difference = vector_sub(lhs, rhs);
return vector_length_squared3_as_scalar(difference);
}

//////////////////////////////////////////////////////////////////////////
// Returns a normalized vector2.
// If the length of the input is not finite or zero, the result is undefined.
Expand Down
18 changes: 18 additions & 0 deletions includes/rtm/vector4f.h
Original file line number Diff line number Diff line change
Expand Up @@ -2319,6 +2319,24 @@ namespace rtm
return vector_length3_as_scalar(difference);
}

//////////////////////////////////////////////////////////////////////////
// Returns the squared distance between two 3D points.
//////////////////////////////////////////////////////////////////////////
RTM_DISABLE_SECURITY_COOKIE_CHECK RTM_FORCE_INLINE rtm_impl::vector4f_vector_dot3 RTM_SIMD_CALL vector_distance_squared3(vector4f_arg0 lhs, vector4f_arg1 rhs) RTM_NO_EXCEPT
{
const vector4f difference = vector_sub(lhs, rhs);
return rtm_impl::vector4f_vector_dot3{ difference, difference };
}

//////////////////////////////////////////////////////////////////////////
// Returns the squared distance between two 3D points.
//////////////////////////////////////////////////////////////////////////
RTM_DISABLE_SECURITY_COOKIE_CHECK RTM_FORCE_INLINE scalarf RTM_SIMD_CALL vector_distance_squared3_as_scalar(vector4f_arg0 lhs, vector4f_arg1 rhs) RTM_NO_EXCEPT
{
const vector4f difference = vector_sub(lhs, rhs);
return vector_length_squared3_as_scalar(difference);
}

//////////////////////////////////////////////////////////////////////////
// Returns a normalized vector2.
// If the length of the input is not finite or zero, the result is undefined.
Expand Down
5 changes: 5 additions & 0 deletions tests/sources/test_vector4_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,11 @@ void test_vector4_arithmetic_impl(const FloatType threshold)
const ScalarType vector_distance3_result_scalar = vector_distance3_as_scalar(test_value0, test_value1);
CHECK(scalar_equal(vector_distance3_result, scalar_cast(vector_distance3_result_scalar)));

const FloatType vector_distance_squared3_result = vector_distance_squared3(test_value0, test_value1);
CHECK(scalar_near_equal(scalar_dot3<Vector4Type, FloatType>(test_value_diff, test_value_diff), vector_distance_squared3_result, scalar_sqrt(threshold)));
const ScalarType vector_distance_squared3_result_scalar = vector_distance_squared3_as_scalar(test_value0, test_value1);
CHECK(scalar_equal(vector_distance_squared3_result, scalar_cast(vector_distance_squared3_result_scalar)));

const Vector4Type scalar_normalize2_result = scalar_normalize2<Vector4Type, FloatType>(test_value0, zero, threshold);
const Vector4Type vector_normalize2_result = vector_normalize2(test_value0);
CHECK(scalar_near_equal(vector_get_x(vector_normalize2_result), vector_get_x(scalar_normalize2_result), threshold));
Expand Down
Loading