forked from BRL-CAD/brlcad
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedars.c
More file actions
83 lines (72 loc) · 1.83 KB
/
Copy pathedars.c
File metadata and controls
83 lines (72 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* E D A R S . C
* BRL-CAD
*
* Copyright (c) 1996-2026 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this file; see the file named COPYING for more
* information.
*/
/** @file mged/edars.c
*
*/
#include "common.h"
#include <math.h>
#include <string.h>
#include "vmath.h"
#include "nmg.h"
#include "raytrace.h"
#include "rt/geom.h"
#include "wdb.h"
#include "./mged.h"
#include "./sedit.h"
#include "./mged_dm.h"
/**
* find which vertex of an ARS is nearest *the ray from "pt" in the
* viewing direction (for vertex selection in MGED)
*/
void
find_ars_nearest_pnt(
int *crv,
int *col,
struct rt_ars_internal *ars,
point_t pick_pt,
vect_t dir)
{
size_t i, j;
int closest_i=0, closest_j=0;
fastf_t min_dist_sq=MAX_FASTF;
RT_ARS_CK_MAGIC(ars);
for (i=0; i<ars->ncurves; i++) {
for (j=0; j<ars->pts_per_curve; j++) {
fastf_t dist_sq;
dist_sq = bg_distsq_line3_pnt3(pick_pt, dir, &ars->curves[i][j*3]);
if (dist_sq < min_dist_sq) {
min_dist_sq = dist_sq;
closest_i = i;
closest_j = j;
}
}
}
*crv = closest_i;
*col = closest_j;
}
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/