g_sph.c File Reference

#include "common.h"
#include <stdio.h>
#include <math.h>
#include "machine.h"
#include "vmath.h"
#include "raytrace.h"
#include "rtgeom.h"
#include "./debug.h"
#include "noalias.h"

Include dependency graph for g_sph.c:

Go to the source code of this file.

Data Structures

struct  sph_specific

Defines

#define 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_class (void)


Detailed Description

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

Authors - Phillip Dykstra Dave Becker (Vectorization)

Source - SECAD/VLD Computing Consortium, Bldg 394 The U. S. Army Ballistic Research Laboratory Aberdeen Proving Ground, Maryland 21005

Definition in file g_sph.c.


Define Documentation

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

Definition at line 280 of file g_sph.c.


Function Documentation

void rt_sph_print register const struct soltab stp  ) 
 

R T _ S P H _ P R I N T

Definition at line 207 of file g_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, 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
 

R T _ S P H _ S H O T

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 240 of file g_sph.c.

References application::a_resource, BU_LIST_INSERT, FAST, seg::l, LOCAL, MAGSQ, RT_GET_SEG, sph_specific::sph_radsq, sph_specific::sph_V, soltab::st_specific, VDOT, and VSUB2.

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

R T _ S P H _ V S H O T

This is the Becker vectorized version

Definition at line 287 of file g_sph.c.

References FAST, hit::hit_dist, LOCAL, MAGSQ, xray::r_pt, seg::seg_in, SEG_MISS, seg::seg_out, seg::seg_stp, sph_specific::sph_radsq, sph_specific::sph_V, VDOT, and VSUB2.

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

R T _ S P H _ N O R M

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

Definition at line 345 of file g_sph.c.

References sph_specific::sph_invrad, sph_specific::sph_V, soltab::st_specific, VJOIN1, VSCALE, and VSUB2.

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

R T _ S P H _ C U R V E

Return the curvature of the sphere.

Definition at line 361 of file g_sph.c.

References bn_vec_ortho(), 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
 

R T _ S P H _ U V

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 381 of file g_sph.c.

References application::a_diverge, application::a_rbeam, bn_atan2(), bn_inv2pi, bn_invpi, LOCAL, MAT4X3VEC, sph_specific::sph_SoR, sph_specific::sph_V, soltab::st_aradius, soltab::st_specific, VSUB2, X, Y, and Z.

Here is the call graph for this function:

void rt_sph_free register struct soltab stp  ) 
 

R T _ S P H _ F R E E

Definition at line 419 of file g_sph.c.

References bu_free().

Here is the call graph for this function:

int rt_sph_class void   ) 
 

Definition at line 428 of file g_sph.c.


Generated on Mon Sep 18 01:25:06 2006 for BRL-CAD by  doxygen 1.4.6