Version 0.55.1

probe::probe

Probes geometric primitive objects with a ray.

Signatures

  •   bool probe( ray r, vector point )
  •   bool probe( ray r, vector point, float epsilon )
  •   bool probe( ray r, vector begin, vector end, vector& hitpoint )
  •   bool probe( ray r, vector begin, vector end, float epsilon, vector& hitpoint )
  •   bool probe( ray r, ray ray, vector& hitpoint )
  •   bool probe( ray r, ray ray, float epsilon, vector& hitpoint )
  •   bool probe( ray r, vector onset, vector dir1, vector dir2, vector& hitpoint )

Details

The function applies a ray probing to various geometric primitives. That means, it checks whether the ray hits the primitve. Function calls (1) and (2) probe a space point, function calls (3) and (4) probe a finite line in space, function calls (5) and (6) probe another ray and function call (7) probes a plane.

An epsilon value can be given for function calls (2), (4) and (6). If ray probes are applied to points, lines and rays in 3d space, the rays will in almost all cases not hit the respective primitives if the evaluation is done with the highest precision level possible. This can be solved by applying a tolerance distance epsilon: if the ray comes within this proximity, the situation counts as a contact. For function calls (1), (3) and (5), this epsilon is set to a default value of 1.0E-7.

Example

 #import( "std/probe.sps" )

 ray r( <[0,0,0]>, <[1,1,1]> )
 vector begin( 2, 0.5, -1 )
 vector end( 0, 0.5, 1 )

 vector hit
 if( probe::probe( r, begin, end, hit ) )
   echo( "Ray hits line segment at " + hit )
 

Output

 Ray hits line segment at <[0.5,0.5,0.5]>
 

Parameters

r

The ray that is used for probing. The probing occurs in positive direction of r only.

point

A point in space. The function checks whether r hits this point with respect to the tolerance distance.

begin

Start point of a line segment. The function checks whether r hits this line with respect to the tolerance distance.

end

End point of a line segment. The function checks whether r hits this line with respect to the tolerance distance.

ray

A ray primitive, i.e. a start point and a direction. The function checks whether r hits this ray with respect to the tolerance distance.

onset

Origin point of a plane in space. The function checks whether r hits this plane.

dir1

First in-plane vector of a plane in space. The function checks whether r hits this plane.

dir2

Second in-plane vector of a plane in space. The function checks whether r hits this plane.

hitpoint

Reference to a vector that returns the 3d point on the primitive in which it gets hit by r. If there is no hit, hitpoint stays unchanged.

epsilon

Tolerance distance: a hit is assumed if r approaches the primitve closer than this. epsilon must be a positive value. Default value is 1.0E-7.

See also

🗙

Search results for