BRL-CAD
#include "common.h"
#include <string.h>
#include <math.h>
#include "bio.h"
#include "vmath.h"
#include "rtgeom.h"
#include "raytrace.h"
Include dependency graph for sph.c:

Go to the source code of this file.

Data Structures

struct  sph_specific
 

Macros

#define RT_SPH_SEG_MISS(SEG)   (SEG).seg_stp=(struct soltab *) 0;
 

Functions

int rt_sph_prep (struct soltab *stp, struct rt_db_internal *ip, struct rt_i *rtip)
 
void rt_sph_print (register const struct soltab *stp)
 
int rt_sph_shot (struct soltab *stp, register struct xray *rp, struct application *ap, struct seg *seghead)
 
void rt_sph_vshot (struct soltab **stp, struct xray **rp, struct seg *segp, int n, struct application *ap)
 
void rt_sph_norm (register struct hit *hitp, struct soltab *stp, register struct xray *rp)
 
void rt_sph_curve (register struct curvature *cvp, register struct hit *hitp, struct soltab *stp)
 
void rt_sph_uv (struct application *ap, struct soltab *stp, register struct hit *hitp, register struct uvcoord *uvp)
 
void rt_sph_free (register struct soltab *stp)
 
int rt_sph_params (struct pc_pc_set *ps, const struct rt_db_internal *ip)
 

Detailed Description

Intersect a ray with a Sphere. Special case of the Generalized Ellipsoid

Definition in file sph.c.

Macro Definition Documentation

#define RT_SPH_SEG_MISS (   SEG)    (SEG).seg_stp=(struct soltab *) 0;

Definition at line 502 of file sph.c.

Referenced by rt_sph_vshot().

Function Documentation

void rt_sph_print ( register const struct soltab stp)

Definition at line 394 of file sph.c.

References bn_mat_print(), bu_log(), sph_specific::sph_invrad, sph_specific::sph_rad, sph_specific::sph_radsq, sph_specific::sph_SoR, sph_specific::sph_V, soltab::st_specific, and VPRINT.

Here is the call graph for this function:

int rt_sph_shot ( struct soltab stp,
register struct xray rp,
struct application ap,
struct seg seghead 
)

Intersect a ray with a sphere. If an intersection occurs, a struct seg will be acquired and filled in.

Notes: In the quadratic equation, A is MAGSQ(r_dir) which is always equal to 1, so it does not appear. The sign of B is reversed (vector is reversed) to save negation. We have factored out the 2 and 4 constants.

Claim: The straight quadratic formula leads to precision problems if either A or C are small. In our case A is always 1. C is a radial distance of the ray origin from the sphere surface. Thus if we are shooting from near the surface we may have problems. XXX - investigate this.

Returns - 0 MISS >0 HIT

Definition at line 427 of file sph.c.

References application::a_resource, BU_LIST_INSERT, hit::hit_dist, hit::hit_surfno, seg::l, xray::r_dir, xray::r_pt, RT_GET_SEG, seg::seg_in, seg::seg_out, seg::seg_stp, sph_specific::sph_radsq, sph_specific::sph_V, and soltab::st_specific.

void rt_sph_vshot ( struct soltab **  stp,
struct xray **  rp,
struct seg segp,
int  n,
struct application ap 
)

This is the Becker vectorized version

Definition at line 507 of file sph.c.

References hit::hit_dist, hit::hit_surfno, xray::r_pt, RT_CK_APPLICATION, RT_SPH_SEG_MISS, seg::seg_in, seg::seg_out, seg::seg_stp, sph_specific::sph_radsq, and sph_specific::sph_V.

void rt_sph_norm ( register struct hit hitp,
struct soltab stp,
register struct xray rp 
)

Given ONE ray distance, return the normal and entry/exit point.

Definition at line 566 of file sph.c.

References hit::hit_dist, hit::hit_normal, hit::hit_point, xray::r_dir, xray::r_pt, sph_specific::sph_invrad, sph_specific::sph_V, and soltab::st_specific.

void rt_sph_curve ( register struct curvature cvp,
register struct hit hitp,
struct soltab stp 
)

Return the curvature of the sphere.

Definition at line 581 of file sph.c.

References bn_vec_ortho(), curvature::crv_c1, curvature::crv_c2, curvature::crv_pdir, hit::hit_normal, sph_specific::sph_invrad, and soltab::st_specific.

Here is the call graph for this function:

void rt_sph_uv ( struct application ap,
struct soltab stp,
register struct hit hitp,
register struct uvcoord uvp 
)

For a hit on the surface of an SPH, return the (u, v) coordinates of the hit point, 0 <= u, v <= 1.

u = azimuth v = elevation

Definition at line 601 of file sph.c.

References application::a_diverge, application::a_rbeam, bn_atan2(), hit::hit_dist, hit::hit_point, sph_specific::sph_SoR, sph_specific::sph_V, soltab::st_aradius, soltab::st_specific, uvcoord::uv_du, uvcoord::uv_dv, uvcoord::uv_u, uvcoord::uv_v, X, Y, and Z.

Here is the call graph for this function:

void rt_sph_free ( register struct soltab stp)

Definition at line 636 of file sph.c.

References BU_PUT, and soltab::st_specific.

int rt_sph_params ( struct pc_pc_set ps,
const struct rt_db_internal ip 
)

Definition at line 646 of file sph.c.

References RT_CK_DB_INTERNAL.