Subject: CGAL users discussion list
List archive
- From: dharmon <>
- To:
- Subject: [cgal-discuss] Re: Getting configuration info from Kinetic Data Structure
- Date: Fri, 13 Jan 2012 13:03:12 -0800 (PST)
I figured this out, so I thought I would share here for posterity.
First, you have to get access to the Point_1 (or Point_2 or Point_3)
structure from the active objects table:
Point_1 pt = *tr.active_points_1_table_handle().at(Point_key(id));
id is the unsigned id of the point of interest. The x() method of Point_1
returns a polynomial whose coefficients can be accessed using the []
operator.
By default, the KDS uses exact arithmetic, so to do something with it you
want to convert it to double using CGAL's built-in conversion tools:
double x = CGAL::to_double(pt.x()[0]);
double v = CGAL::to_double(pt.x()[1]);
For linear trajectories, the above is sufficient to get the point's
positions at all times, x+v*t. Now, one key thing is that the stored
positions are based at t=0. so if t_curr is the current time, the current
position is actually,
double x_curr = x + v * t_curr;
It is not just x. From this, you can figure out how to adjust x and v for
impulse changes in velocity.
double x_new = (x + v * t_curr) - v_new * t_curr;
// Construct new Point_1 from (x_new,v_new)
*tr.active_points_1_table_handle().set(pt_new);
That's it. For Point_2 there is a y() method that gives the polynomial
describing the y-coordinate trajectory. Similarly, Point_3 has a z() method.
Hopefully someone finds this helpful.
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Getting-configuration-info-from-Kinetic-Data-Structure-tp4270911p4293418.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Getting configuration info from Kinetic Data Structure, dharmon, 01/06/2012
- [cgal-discuss] Re: Getting configuration info from Kinetic Data Structure, dharmon, 01/13/2012
Archive powered by MHonArc 2.6.16.