BRL-CAD
lseg.h
Go to the documentation of this file.
1/* L S E G . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2004-2023 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20
21/*----------------------------------------------------------------------*/
22/* @file lseg.h */
23/** @addtogroup bg_lseg */
24/** @{ */
25
26/**
27 * @brief Functions for working with line segments
28 */
29
30#ifndef BG_LSEG_H
31#define BG_LSEG_H
32
33#include "common.h"
34#include "vmath.h"
35#include "bv.h"
36#include "bg/defines.h"
37
38__BEGIN_DECLS
39
40/* Compute the closest point on the line segment P0->P1 to point Q. Returns
41 * the distance squared from Q to the closest point and the closest point in
42 * question if c is non-NULL.
43 */
44BG_EXPORT double
45bg_distsq_lseg3_pt(point_t *c, const point_t P0, const point_t P1, const point_t Q);
46
47/* Compute the closest points on the line segments P0->P1 and Q0->Q1. Returns
48 * the distance squared between the closest points and (optionally) the closest
49 * points in question (c1 is the point on P0->P1, c2 is the point on Q0->Q1).
50 */
51BG_EXPORT double
53 const point_t P0, const point_t P1, const point_t Q0, const point_t Q1);
54
55
56/* Logic for snapping points to their closes view lines.
57 * TODO - really should make this generic to any line set, not just the
58 * bv structures. */
59
60/* Snap sample 2D point to lines active in the view */
61BG_EXPORT extern int bv_snap_lines_2d(struct bview *v, fastf_t *fx, fastf_t *fy);
62
63/* Snap sample 2D point to grid active in the view */
64BG_EXPORT extern int bv_snap_grid_2d(struct bview *v, fastf_t *fx, fastf_t *fy);
65
66/* Snap sample 3D point to lines active in the view */
67BG_EXPORT extern int bv_snap_lines_3d(point_t *out_pt, struct bview *v, point_t *p);
68
69
70BG_EXPORT extern void bv_view_center_linesnap(struct bview *v);
71
72
73
74__END_DECLS
75
76#endif /* BG_LSEG_H */
77/** @} */
78/*
79 * Local Variables:
80 * mode: C
81 * tab-width: 8
82 * indent-tabs-mode: t
83 * c-file-style: "stroustrup"
84 * End:
85 * ex: shiftwidth=4 tabstop=8
86 */
Header file for the BRL-CAD common definitions.
double bg_distsq_lseg3_pt(point_t *c, const point_t P0, const point_t P1, const point_t Q)
Functions for working with line segments.
int bv_snap_lines_3d(point_t *out_pt, struct bview *v, point_t *p)
int bv_snap_grid_2d(struct bview *v, fastf_t *fx, fastf_t *fy)
int bv_snap_lines_2d(struct bview *v, fastf_t *fx, fastf_t *fy)
void bv_view_center_linesnap(struct bview *v)
double bg_distsq_lseg3_lseg3(point_t *c1, point_t *c2, const point_t P0, const point_t P1, const point_t Q0, const point_t Q1)
void float float * fy
Definition: tig.h:283
void float * fx
Definition: tig.h:282
void int * c
Definition: tig.h:139
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:330
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition: vmath.h:351
Definition: defines.h:476
fundamental vector, matrix, quaternion math macros