Jump to content
  • Advertisement

Wizumwalt

Member
  • Content Count

    158
  • Joined

  • Last visited

Community Reputation

161 Neutral

About Wizumwalt

  • Rank
    Member

Personal Information

  • Interests
    Design
  1. Wizumwalt

    How to get RPY and plugin to Quaternion

    The code I posted shows the conversion from RPY to quaternions, so it does help with that. What I'm looking for are the values to feed into a quaternion from my current orientation. Then I can combine the two by multiplying those quats together to get the new value and feed that in. But I don't understand how to get the value from my current orientation to the new orientation. Does that make sense? It's not a problem with the API, it's the value that I feed in to get me to my new orientation.
  2. I have an API that takes quaternions to set the orientation of a drone. I want to fix the roll, pitch, and yaw. I currently have the following. tf::Quaternion q_new, q_curr, q_rot; // r, p, y is current vehicle orientation q_curr = tf::createQuaternionFromRPY(r, p, y); // What to plug in here ... q_rot = tf::createQuaternionFromRPY(?, ?, ?); // I think this is how to apply the new orientation to the current q_new = q_curr * q_rot; q_new.normalize(); My problem is I don't know what values to plugin to q_rot to set the new orientation. I can think in RPY values, but not quaternions. For example, I'd like to rotate the drone around the z-axis 90 degrees, or 180 around y, or 90 degrees around the x axis, etc... How does one calculate that?
  3. Wizumwalt

    2D proportional point plots

    Hi, I have a set of 2D points to plot. Each set can contain any range of values. The bounds of my window can be resized to change also. My problem is that I can't find a formula that will proportionally plot my points in the canvas space correctly no matter what the window size or range of values are. Can anyone help w/ this formula?
  4. Wizumwalt

    scale scatter plot

    I'm drawing a scatter plot and in this case, all of my points (NSRect's) in pointsArray are float values between -1 and 1. My problem is that I can't seem to scale my view according to the values of my pointsArray. So, if my values are all between -1 and 1, my view size should show a scatter plot w/ x-axis boundaries -1 to 1, so as to show my points in proportion to the screen. Can anyone help out w/ what I'm doing wrong here? - (void) drawScatter { float xFactor = 0.0; float yFactor = 0.0; NSRect bounds = [self bounds]; float xabs = fabs(minXValue) + fabs(maxXValue); float yabs = fabs(minYValue) + fabs(maxYValue); xFactor = (bounds.size.width / 2) + (bounds.size.width * 0.10); yFactor = (bounds.size.height / 2) + (bounds.size.height * 0.10); // Move to origin in center of screen. NSAffineTransform *xform = [NSAffineTransform transform]; [xform translateXBy:(bounds.size.width / 2) yBy:(bounds.size.height / 2)]; if (xFactor > yFactor) { [xform scaleBy:(xFactor / 2)]; } else { [xform scaleBy:(yFactor / 2)]; } id pp; NSEnumerator *enumerator = [pointsArray objectEnumerator]; while (pp = [enumerator nextObject]) { NSBezierPath *pointPath = [NSBezierPath bezierPath]; [pointPath appendBezierPathWithOvalInRect:[pp point]]; [pointPath transformUsingAffineTransform:xform]; if ([pp outputResult] > 0) { [[NSColor redColor] setStroke]; [[NSColor whiteColor] setFill]; } else { [[NSColor blueColor] setStroke]; [[NSColor whiteColor] setFill]; } [pointPath stroke]; } return; } - (void)drawRect:(NSRect) rect { NSRect bounds = [self bounds]; [[NSColor blackColor] setFill]; [NSBezierPath fillRect:bounds]; [self drawScatterPlotAxes]; [self drawScatter]; }
  5. Wizumwalt

    scaling of 2D scatter plot coords

    Yes, I believe you've pretty much nailed it. I've got a window that can be resized to any size and I want my plot points (which are user defined and can be any value) to take up the full window so the data can be analyzed correctly. And the X and Y labels will only show the range of values plotted. I think you explained it correctly.
  6. I have a few hundred points which I'm trying to draw as a scatter plot. The origin of my plot (0,0) is in the center of my canvas where my crosshairs are. My values in this case are no larger than 0.998 and no less than -0.932. Though the values can always change so I'm trying to scale my graph according the whatever values are read in. And that's where I'm having my problem. I'm trying to draw circles at each point on my canvas so that they are proportional to the view size (window boundaries). So, for example, with a value like (x = 0.79, y=0.93), my X and Y scales would not be 500x500, else all the coords would show up as dots in the middle of the view. Can anyone help w/ how I should calculate x,y coords to my 2D plot proportionally? But my values can be in any range. Any help much appreciated.
  7. Hi, I have a few hundred points which I'm trying to draw as a scatter plot. The origin of my plot (0,0) is in the center of my canvas where my crosshairs are. My values in this case are no larger than 0.998 and no less than -0.932. Though the values can always change so I'm trying to scale my graph according the whatever values are read in. And that's where I'm having a problem, can someone look this over and help with my scaling? I'm trying to draw circles at each point on my view. So if my values are between -1.0 and 1.0, then my view boundaries should be between -1 and 1, and if I had values of -1233.0 and 2321.0, then my view boundaries should be proportional. After looking at this a bit more, I think I may have more wrong than scaling. But I can't figure it out. - (void) drawRect:(NSRect) rect { NSRect bounds = [self bounds]; [[NSColor blackColor] setFill]; [NSBezierPath fillRect:bounds]; [self drawScatterPlotAxes]; [self drawScatter]; return; } - (void) drawScatter { NSRect bounds = [self bounds]; float xFactor = (bounds.size.width * 0.5) / maxXValue; float yFactor = (bounds.size.height * 0.5) / maxYValue; NSBezierPath *copyPath = [circlePath copy]; NSAffineTransform *xform = [NSAffineTransform transform]; // goto center of screen where 0,0 is located to start drawing. [xform translateXBy:(bounds.size.width * 0.50) yBy:(bounds.size.height * 0.50)]; [xform scaleXBy:(xFactor / 2) yBy:(yFactor / 2)]; [copyPath transformUsingAffineTransform:xform]; [[NSColor yellowColor] setStroke]; [copyPath stroke]; return; } - (void) addCoord:(double) xval yCoord:(double) yval { NSRect rect = NSMakeRect(xval, yval, 3, 3); [circlePath appendBezierPathWithOvalInRect:rect]; }
  8. Wizumwalt

    coords into world units

    I'm trying to convert a GPS devices coords into my game. I have numbers from a GPS device like ... 4807.038 01131.000 from which the GPS device docs say this means ... 4807.038,N Latitude 48 deg 07.038' N 01131.000,E Longitude 11 deg 31.000' E I'm trying to convert these into x and y coordinates so that I can then plot them, but I'm not sure how to convert them into world units that I can scale to say a world size of 1000 or 5000 or whatever I want to change that to. Can anyone help w/ a formula to convert these coordinates into x y coordinates on a plot that can be scaled? [Edited by - Wizumwalt on December 23, 2009 2:39:40 PM]
  9. Wizumwalt

    help create events w/ boost

    Quote:Original post by Sc4Freak In your case, I'm guessing you don't really want a priority_queue here. priority_queue is sorted in that the top of the queue is the one with the largest value. I think you're looking more for std::stack or a regular std::queue, depending on if you want FIFO or LIFO behaviour. Thanks, this is very helpful, but I'm thinking I need a priority_queue and prioritize from the event w/ the least amount of time, and once the current_time is > than the item on the priority_queue w/ the least amount of seconds, then it gets executed (time's expired, exec event). I will always be looking for the event w/ the lowest amount of time in the queue because only that one can be executed next. Is my thinking correct there?
  10. Wizumwalt

    help create events w/ boost

    Quote:Original post by Sc4Freak In short, the code doesn't really make sense (or is very horribly broken). I suspect you've tried to type out your code from memory and messed it up - don't do this. Copy and paste the exact code you're trying to compile. We can help, but we need more information first. Yeah, it was horribly broken and didn't make sense. I'm having a hard time understanding, but I've gotten a bit further and think this is more correct, but a few questions ... // Is storing a function object onto a queue like below allowable? I'm getting // errors I can't even begin to understand (posted at bottom). class Scheduler { private: typedef boost::function<void ()> event; std::priority_queue<event> pq; public: void at(time_t when, event const& what); } // Here I create 3 function objects (events) and put them on a queue. void MyApp::initTimer() { type_t now = current_time(); for (int i = 0; i < 3; i++) { event = bind(&MyApp::print, this); scheduler->at(now + i, event); } } // But here I'm losing the time when this event is to be excuted. // How do I store the time so that I can check it in my run() and see // if time has expired so that it can be executed? void Scheduler::at(time_t when, event const& what) { pq.push(what); } // This function gets run in every frame of my game. I was hoping to just // pull off the top() of the queue, see if time expired, and if so execute the // function bound to the event. But I think my at() is messed up. scheduler->run(); And the error I get compiling ... /bin/sh ../../../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../../../dnr/src/libs/events -I../../.. -I../../../../dnr/include -I/usr/local/include/OGRE -g -O2 -MT Scheduler.lo -MD -MP -MF .deps/Scheduler.Tpo -c -o Scheduler.lo ../../../../dnr/src/libs/events/Scheduler.cpp g++ -DHAVE_CONFIG_H -I. -I../../../../dnr/src/libs/events -I../../.. -I../../../../dnr/include -I/usr/local/include/OGRE -g -O2 -MT Scheduler.lo -MD -MP -MF .deps/Scheduler.Tpo -c ../../../../dnr/src/libs/events/Scheduler.cpp -fPIC -DPIC -o .libs/Scheduler.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_function.h: In member function 'bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = boost::function<void ()(), std::allocator<void> >]': /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_heap.h:279: instantiated from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<boost::function<void ()(), std::allocator<void> >*, std::vector<boost::function<void ()(), std::allocator<void> >, std::allocator<boost::function<void ()(), std::allocator<void> > > > >, _Distance = long int, _Tp = boost::function<void ()(), std::allocator<void> >, _Compare = std::less<boost::function<void ()(), std::allocator<void> > >]' /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_heap.h:404: instantiated from 'void std::make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<boost::function<void ()(), std::allocator<void> >*, std::vector<boost::function<void ()(), std::allocator<void> >, std::allocator<boost::function<void ()(), std::allocator<void> > > > >, _Compare = std::less<boost::function<void ()(), std::allocator<void> > >]' /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_queue.h:367: instantiated from 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&) [with _Tp = boost::function<void ()(), std::allocator<void> >, _Sequence = std::vector<boost::function<void ()(), std::allocator<void> >, std::allocator<boost::function<void ()(), std::allocator<void> > > >, _Compare = std::less<boost::function<void ()(), std::allocator<void> > >]' ../../../../dnr/src/libs/events/Scheduler.cpp:11: instantiated from here /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_function.h:227: error: no match for 'operator<' in '__x < __y' make[4]: *** [Scheduler.lo] Error 1
  11. I'm new to boost and what I'm doing seems very simple, but I can't get it. I want to store 3 events onto a priority_queue and have them execute n seconds from the time they were created, n is a randomly generated amount of time between 0 and 10 seconds. // create container that holds function objects priority_queue<boost::function<void (Event)> > pq; // create 3 events and place in priority_queue boost::bind(destroy_target, placeholders::_1, 'pq'); boost::bind(destroy_target, placeholders::_1, 'pq'); boost::bind(destroy_target, placeholders::_1, 'pq'); I think I now have 3 function objects on the queue, but I don't know how to pull the Event object off the queue and check f it's timestamp is expired, and if so execute the function object that was stored on the queue. // get the first event off the priority_queue, and if expired, execute destroy_target(). Event e = pq.top()(Event()); // this is the function I eventually want my event to execute void destroy_target() { ... } Any help is greatly appreciated.
  12. Well, the monster is not going anywhere's so ... I don't see why it would go away. I don't plan on deleting it. Now I'm wondering what you mean and if I should go back to a priority_queue.
  13. Ok, this turns out to be a really good reason for me to learn boost. So I'm trying to create 10 events that will start from a random amount of time between now and 10 seconds. I have the random generating code function that works. And I'm trying to have a scheduler execute my events at *that* randomly generated time. I have this at the top of one of my *.cpp files typedef boost::function<void ()> event; Then here I create the event which I think binds the die function of the Monster class to this void function called 'killMonster'. What does the second argument do? This just creates the event and schedules it? Is this context.scheduler a part of boost or ... where can I find more about creating a scheduler? event killMonster = boost::bind(&Monster::die, this -> target); this -> context.scheduler.at(NOW + 3.0, killMonster); Then I have a function that is called between every frame of my game, so that's where I planned on checking the time of the event to see if it had expired. Can someone elaborate as to this ... I don't understand how that fits in with step_length. time += step_length; this -> context.scheduler.run(time);
  14. I will constantly add events to the queue throughout the life of the program and need for the event w/ the least amount to be the one I pull off. The times are generated randomly and I don't control how they get put on the queue. And more can be added at anytime w/ a lesser timestamp.
  15. Hi, I'm trying to create a central event system for my game where I add some events to a priority_queue and pull off the first one as soon as it expires. But I'm have a problem of understand if I'm adding them to the queue correctly, if they're in order, and how to pull them off. Can anyone lend a hand here? Here I initialize my priority queue. my_queue = new MyEventQueue(); Then I create 10 events adding the current time and a generated random time between 0 and 15 seconds (so that the event executes x number of seconds from the time they are created) and put them on a queue. for (int i = 0; i < 10; i++) { MyEvent *event = new MyEvent(); event->set_start_timestamp(); // now time event->set_execute_timestamp(); // time to execute from now my_queue->push_event(event); } Then in each frame of my game, I check the queue to see if the event is ready to be executed. if (my_queue->count() > 0) { MyEvent *evnt = my_queue->top_event(); // is_expired() is how i was doing it, but didn't work if (evnt->is_expired()) { execute_event(evnt->id()); my_queue->pop_event(); } } And here are my event classes, and this overloading is really confusing me, not sure this is even close to correct. class MyEvent { ... public: ... bool is_expired(); struct timeval start_timestamp(); double execute_timestamp(); }; struct EventPointerCompare { bool operator() (MyEvent* lhs, MyEvent* rhs) const { return ( lhs->_execute_time < rhs->_execute_time ); } }; // this is my priority_queue wrapper class MyEventQueue { private: priority_queue<MyEvent *, vector<MyEvent *>, EventPointerCompare> event_queue; public: check_queue(); has_events_of_type_x(); ... Can anyone help me understand and what I need yet to do to make this work? [Edited by - Wizumwalt on October 22, 2008 1:25:51 AM]
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!