Revision: 73839
http://sourceforge.net/p/brlcad/code/73839
Author: bob1961
Date: 2019-09-05 20:32:45 +0000 (Thu, 05 Sep 2019)
Log Message:
-----------
Exposed a bit of libbn's functionality through libged's interface. At the
moment it's only mat_ae, mat_mul, mat4x3pnt and mat_scale_about_pt.
Modified Paths:
--------------
brlcad/trunk/include/ged/commands.h
brlcad/trunk/src/libged/CMakeLists.txt
Added Paths:
-----------
brlcad/trunk/src/libged/libfuncs.c
Modified: brlcad/trunk/include/ged/commands.h
===================================================================
--- brlcad/trunk/include/ged/commands.h 2019-09-05 16:30:50 UTC (rev 73838)
+++ brlcad/trunk/include/ged/commands.h 2019-09-05 20:32:45 UTC (rev 73839)
@@ -171,6 +171,26 @@
GED_EXPORT extern int ged_make_name(struct ged *gedp, int argc, const char
*argv[]);
/**
+ * Multiply a point by a 4x4 matrix yielding the transformed point
+ */
+GED_EXPORT extern int ged_mat4x3pnt(struct ged *gedp, int argc, const char
*argv[]);
+
+/**
+ * Create a matrix given an azimuth and elevation
+ */
+GED_EXPORT extern int ged_mat_ae(struct ged *gedp, int argc, const char
*argv[]);
+
+/**
+ * Create a matrix that is the result of multiplying the two specified matrices
+ */
+GED_EXPORT extern int ged_mat_mul(struct ged *gedp, int argc, const char
*argv[]);
+
+/**
+ * Create a matrix that will scale about a given point
+ */
+GED_EXPORT extern int ged_mat_scale_about_pt(struct ged *gedp, int argc, const
char *argv[]);
+
+/**
* Modify material information.
*/
GED_EXPORT extern int ged_mater(struct ged *gedp, int argc, const char
*argv[]);
Modified: brlcad/trunk/src/libged/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libged/CMakeLists.txt 2019-09-05 16:30:50 UTC (rev
73838)
+++ brlcad/trunk/src/libged/CMakeLists.txt 2019-09-05 20:32:45 UTC (rev
73839)
@@ -172,6 +172,7 @@
killtree.c
label.c
lc.c
+ libfuncs.c
lint.cpp
list.c
loadview.c
Added: brlcad/trunk/src/libged/libfuncs.c
===================================================================
--- brlcad/trunk/src/libged/libfuncs.c (rev 0)
+++ brlcad/trunk/src/libged/libfuncs.c 2019-09-05 20:32:45 UTC (rev 73839)
@@ -0,0 +1,147 @@
+/* L I B F U N C S . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2004-2019 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 libged/libfuncs.c
+ *
+ * BRL-CAD's libged wrappers for various libraries.
+ *
+ */
+
+#include "common.h"
+
+#include "ged.h"
+
+int
+ged_mat_ae(struct ged *gedp,
+ int argc,
+ const char *argv[])
+{
+ mat_t o;
+ double az, el;
+ static const char *usage = "az el";
+
+ GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
+ GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
+
+ /* initialize result */
+ bu_vls_trunc(gedp->ged_result_str, 0);
+
+ if (argc < 3 ||
+ bu_sscanf(argv[1], "%lf", &az) != 1 ||
+ bu_sscanf(argv[2], "%lf", &el) != 1) {
+ bu_vls_printf(gedp->ged_result_str, "usage: %s %s", argv[0], usage);
+ return GED_ERROR;
+ }
+
+ bn_mat_ae(o, (fastf_t)az, (fastf_t)el);
+ bn_encode_mat(gedp->ged_result_str, o, 1);
+
+ return GED_OK;
+}
+
+
+int
+ged_mat_mul(struct ged *gedp,
+ int argc,
+ const char *argv[])
+{
+ mat_t o, a, b;
+ static const char *usage = "matA matB";
+
+ GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
+ GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
+
+ /* initialize result */
+ bu_vls_trunc(gedp->ged_result_str, 0);
+
+ if (argc < 3 || bn_decode_mat(a, argv[1]) < 16 ||
+ bn_decode_mat(b, argv[2]) < 16) {
+ bu_vls_printf(gedp->ged_result_str, "usage: %s %s", argv[0], usage);
+ return GED_ERROR;
+ }
+
+ bn_mat_mul(o, a, b);
+ bn_encode_mat(gedp->ged_result_str, o, 1);
+
+ return GED_OK;
+}
+
+
+int
+ged_mat4x3pnt(struct ged *gedp,
+ int argc,
+ const char *argv[])
+{
+ mat_t m;
+ point_t i, o;
+ static const char *usage = "mat pt";
+
+ GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
+ GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
+
+ MAT_ZERO(m);
+
+ /* initialize result */
+ bu_vls_trunc(gedp->ged_result_str, 0);
+
+ if (argc < 3 || bn_decode_mat(m, argv[1]) < 16 ||
+ bn_decode_vect(i, argv[2]) < 3) {
+ bu_vls_printf(gedp->ged_result_str, "usage: %s %s", argv[0], usage);
+ return GED_ERROR;
+ }
+
+ MAT4X3PNT(o, m, i);
+ bn_encode_vect(gedp->ged_result_str, o, 1);
+
+ return GED_OK;
+}
+
+
+int
+ged_mat_scale_about_pt(struct ged *gedp,
+ int argc,
+ const char *argv[])
+{
+ mat_t o;
+ vect_t v;
+ double scale;
+ static const char *usage = "pt scale";
+
+ GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
+ GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
+
+ /* initialize result */
+ bu_vls_trunc(gedp->ged_result_str, 0);
+
+ if (argc < 3 || bn_decode_vect(v, argv[1]) < 3 ||
+ bu_sscanf(argv[2], "%lf", &scale) != 1) {
+ bu_vls_printf(gedp->ged_result_str, "usage: %s %s", argv[0], usage);
+ return GED_ERROR;
+ }
+
+ if (bn_mat_scale_about_pt(o, v, scale) != 0) {
+ bu_vls_printf(gedp->ged_result_str, "error performing calculation");
+ return GED_ERROR;
+ }
+
+ bn_encode_mat(gedp->ged_result_str, o, 1);
+
+ return GED_OK;
+}
Property changes on: brlcad/trunk/src/libged/libfuncs.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits