/**
 * For a hit on the surface of an METABALL, return the (u, v)
 * coordinates of the hit point, 0 <= u, v <= 1.
 *
 * u = azimuth
 * v = elevation
 */
void
rt_metaball_uv(struct application *ap, struct soltab *stp, struct hit *hitp, struct uvcoord *uvp)
{
    struct rt_metaball_internal *metaball = (struct rt_metaball_internal *)stp->st_specific;
    vect_t work, pprime;
    fastf_t r;

    if (ap) RT_CK_APPLICATION(ap);
    if (stp) RT_CK_SOLTAB(stp);
    if (hitp) RT_CK_HIT(hitp);
    if (!uvp) return;
    if (!metaball) return;

    /* stuff stolen from sph */
    VSUB2(work, hitp->hit_point, stp->st_center);
    VSCALE(pprime, work, 1.0/MAGNITUDE(work));
    /* Assert that pprime has unit length */

    /* U is azimuth, atan() range: -pi to +pi */
    uvp->uv_u = bn_atan2(pprime[Y], pprime[X]) * M_1_2PI;
    if (uvp->uv_u < 0)
	uvp->uv_u += 1.0;
    /*
     * V is elevation, atan() range: -pi/2 to +pi/2, because sqrt()
     * ensures that X parameter is always >0
     */
    uvp->uv_v = bn_atan2(pprime[Z],
			 sqrt(pprime[X] * pprime[X] + pprime[Y] * pprime[Y])) * M_1_2PI;

    /* approximation: r / (circumference, 2 * pi * aradius) */
    r = ap->a_rbeam + ap->a_diverge * hitp->hit_dist;
    uvp->uv_du = uvp->uv_dv =
	M_1_2PI * r / stp->st_aradius;
    return;
}
Esempio n. 2
0
int
rt_obj_uv(struct application *ap, struct soltab *stp, struct hit *hitp, struct uvcoord *uvp)
{
    int id;
    const struct rt_functab *ft;

    if (!stp || !hitp || !uvp)
	return -1;

    RT_CK_SOLTAB(stp);
    RT_CK_HIT(hitp);
    if (ap) RT_CK_APPLICATION(ap);

    id = stp->st_id;
    if (id < 0)
	return -2;

    ft = &rt_functab[id];
    if (!ft)
	return -3;
    if (!ft->ft_uv)
	return -4;

    ft->ft_uv(ap, stp, hitp, uvp);
    return 0;
}
int
rt_obj_norm(struct hit *hitp, struct soltab *stp, struct xray *rp)
{
    int id;
    const struct rt_functab *ft;

    if (!hitp || !stp)
	return -1;

    RT_CK_SOLTAB(stp);
    RT_CK_HIT(hitp);
    if (rp) RT_CK_RAY(rp);

    id = stp->st_id;
    if (id < 0)
	return -2;

    ft = &OBJ[id];
    if (!ft)
	return -3;
    if (!ft->ft_norm)
	return -4;

    ft->ft_norm(hitp, stp, rp);
    return 0;
}
Esempio n. 4
0
/**
 * R T _ P G _ C U R V E
 */
void
rt_pg_curve(struct curvature *cvp, struct hit *hitp, struct soltab *stp)
{
    if (!cvp || !hitp)
	return;
    RT_CK_HIT(hitp);
    if (stp) RT_CK_SOLTAB(stp);

    bn_vec_ortho(cvp->crv_pdir, hitp->hit_normal);
    cvp->crv_c1 = cvp->crv_c2 = 0;
}
Esempio n. 5
0
/**
 * R T _ P G _ N O R M
 */
void
rt_pg_norm(struct hit *hitp, struct soltab *stp, struct xray *rp)
{
    if (!hitp || !stp || !rp)
	return;
    RT_CK_HIT(hitp);
    RT_CK_SOLTAB(stp);
    RT_CK_RAY(rp);

    /* Normals computed in rt_pg_shot, nothing to do here */
}
Esempio n. 6
0
/**
 * Return the curvature of the superellipsoid.
 */
void
rt_superell_curve(struct curvature *cvp, struct hit *hitp, struct soltab *stp)
{
    if (!cvp || !hitp || !stp)
        return;
    RT_CK_HIT(hitp);
    RT_CK_SOLTAB(stp);

    bu_log("called rt_superell_curve()\n");
    return;
}
Esempio n. 7
0
File: pr.c Progetto: kanzure/brlcad
void
rt_pr_hit(const char *str, register const struct hit *hitp)
{
    struct bu_vls v = BU_VLS_INIT_ZERO;

    RT_CK_HIT(hitp);

    rt_pr_hit_vls(&v, str, hitp);
    bu_log("%s", bu_vls_addr(&v));
    bu_vls_free(&v);
}
/**
 * Return the curvature of the metaball.
 */
void
rt_metaball_curve(struct curvature *cvp, struct hit *hitp, struct soltab *stp)
{
    struct rt_metaball_internal *metaball = (struct rt_metaball_internal *)stp->st_specific;

    if (!metaball || !cvp) return;
    if (hitp) RT_CK_HIT(hitp);

    bu_log("ERROR: rt_metaball_curve() is not implemented\n");
    return;
}
Esempio n. 9
0
/**
 * For a hit on the surface of an SUPERELL, return the (u, v) coordinates
 * of the hit point, 0 <= u, v <= 1.
 * u = azimuth
 * v = elevation
 */
void
rt_superell_uv(struct application *ap, struct soltab *stp, struct hit *hitp, struct uvcoord *uvp)
{
    if (ap) RT_CK_APPLICATION(ap);
    if (!stp || !hitp || !uvp)
        return;
    RT_CK_SOLTAB(stp);
    RT_CK_HIT(hitp);

    bu_log("called rt_superell_uv()\n");
    return;
}
Esempio n. 10
0
File: pr.c Progetto: kanzure/brlcad
void
rt_pr_hit_vls(struct bu_vls *v, const char *str, register const struct hit *hitp)
{
    BU_CK_VLS(v);
    RT_CK_HIT(hitp);

    bu_log_indent_vls(v);
    bu_vls_strcat(v, str);

    bu_vls_printf(v, "HIT dist=%g (surf %d)\n",
		  hitp->hit_dist, hitp->hit_surfno);
}
Esempio n. 11
0
/**
 * R T _ P G _ U V
 */
void
rt_pg_uv(struct application *ap, struct soltab *stp, struct hit *hitp, struct uvcoord *uvp)
{
    if (ap) RT_CK_APPLICATION(ap);
    if (stp) RT_CK_SOLTAB(stp);
    if (hitp) RT_CK_HIT(hitp);
    if (!uvp)
	return;

    /* Do nothing.  Really, should do what ARB does. */
    uvp->uv_u = uvp->uv_v = 0;
    uvp->uv_du = uvp->uv_dv = 0;
}
Esempio n. 12
0
/**
 * Return the curvature of the revolve.
 */
void
rt_revolve_curve(struct curvature *cvp, struct hit *hitp, struct soltab *stp)
{
    if (!cvp || !hitp)
	return;
    RT_CK_HIT(hitp);
    if (stp) RT_CK_SOLTAB(stp);

    cvp->crv_c1 = cvp->crv_c2 = 0;

    /* any tangent direction */
    bn_vec_ortho(cvp->crv_pdir, hitp->hit_normal);
}
Esempio n. 13
0
File: xxx.c Progetto: kanzure/brlcad
/**
 * For a hit on the surface of an xxx, return the (u, v) coordinates
 * of the hit point, 0 <= u, v <= 1.

 * u = azimuth,  v = elevation
 */
void
rt_xxx_uv(struct application *ap, struct soltab *stp, struct hit *hitp, struct uvcoord *uvp)
{
    struct xxx_specific *xxx;

    if (ap) RT_CK_APPLICATION(ap);
    if (!stp || !uvp) return;
    RT_CK_SOLTAB(stp);
    if (hitp) RT_CK_HIT(hitp);

    xxx = (struct xxx_specific *)stp->st_specific;
    if (!xxx) return;
}
Esempio n. 14
0
/**
 * For a hit on a face of an ARB, return the (u, v) coordinates
 * of the hit point.  0 <= u, v <= 1.
 * u extends along the arb_U direction defined by B-A,
 * v extends along the arb_V direction defined by Nx(B-A).
 */
void
rt_arbn_uv(struct application *ap, struct soltab *stp, struct hit *hitp, struct uvcoord *uvp)
{
    struct rt_arbn_internal *arbn = (struct rt_arbn_internal *)stp->st_specific;

    if (ap) RT_CK_APPLICATION(ap);
    RT_ARBN_CK_MAGIC(arbn);
    if (hitp) RT_CK_HIT(hitp);

    if (uvp) {
	uvp->uv_u = uvp->uv_v = 0;
	uvp->uv_du = uvp->uv_dv = 0;
    }
}
Esempio n. 15
0
File: pr.c Progetto: kanzure/brlcad
void
rt_pr_hitarray_vls(struct bu_vls *v, const char *str, register const struct hit *hitp, int count)
{
    int i;

    BU_CK_VLS(v);
    RT_CK_HIT(hitp);

    bu_log_indent_vls(v);
    bu_vls_strcat(v, str);

    for (i=0; i<count; i++, hitp++) {
	bu_vls_printf(v, "HIT%d dist=%g (surf %d)\n", i,
		      hitp->hit_dist, hitp->hit_surfno);
    }
}