lygia
/v1.1.6
/geometry
/triangle
/signedDistance
)returns the signed distance from the surface of a triangle to a point
Dependencies:
lygia
/v1.1.6
/geometry
/triangle
/triangle
.glsl
lygia
/v1.1.6
/geometry
/triangle
/normal
.glsl
lygia
/v1.1.6
/geometry
/triangle
/closestPoint
.glsl
Use:
<vec3> closestDistance(<Triangle> tri, <vec3> _pos)
#ifndef FNC_TRIANGLE_SIGNED_DISTANCE
#define FNC_TRIANGLE_SIGNED_DISTANCE
float signedDistance(Triangle _tri, vec3 _triNormal, vec3 _p) {
vec3 nearest = closestPoint(_tri, _triNormal, _p);
vec3 delta = _p - nearest;
float distance = length(delta);
distance *= sign( dot(delta/distance, _triNormal) );
return distance;
}
float signedDistance(Triangle _tri, vec3 _p) { return signedDistance(_tri, normal(_tri), _p); }
#endif
Dependencies:
lygia
/v1.1.6
/geometry
/triangle
/triangle
.glsl
lygia
/v1.1.6
/geometry
/triangle
/normal
.glsl
lygia
/v1.1.6
/geometry
/triangle
/closestPoint
.glsl
Use:
<float3> closestDistance(<Triangle> tri, <float3> _pos)
#ifndef FNC_TRIANGLE_SIGNED_DISTANCE
#define FNC_TRIANGLE_SIGNED_DISTANCE
float signedDistance(Triangle _tri, float3 _triNormal, float3 _p) {
float3 nearest = closestPoint(_tri, _triNormal, _p);
float3 delta = _p - nearest;
float distance = length(delta);
distance *= sign( dot(delta/distance, _triNormal) );
return distance;
}
float signedDistance(Triangle _tri, float3 _p) { return signedDistance(_tri, normal(_tri), _p); }
#endif
Dependencies:
lygia
/v1.1.6
/geometry
/triangle
/triangle
.glsl
lygia
/v1.1.6
/geometry
/triangle
/normal
.glsl
lygia
/v1.1.6
/geometry
/triangle
/closestPoint
.glsl
lygia
/v1.1.6
/math
/length
.glsl
lygia
/v1.1.6
/math
/sign
.glsl
lygia
/v1.1.6
/math
/operations
.glsl
Use:
<float3> closestDistance(<Triangle> tri, <float3> _pos)
#ifndef FNC_TRIANGLE_SIGNED_DISTANCE
#define FNC_TRIANGLE_SIGNED_DISTANCE
inline __host__ __device__ float signedDistance(const Triangle& _tri, const float3& _triNormal, const float3& _p) {
float3 nearest = closestPoint(_tri, _triNormal, _p);
float3 delta = _p - nearest;
float distance = length(delta);
distance *= sign( dot(delta/distance, _triNormal) );
return distance;
}
inline __host__ __device__ float signedDistance(const Triangle& _tri, const float3& _p) { return signedDistance(_tri, normal(_tri), _p); }
#endif
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository