Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

402 Neutral

About aryx

  • Rank
  1. Ahh yes, my mistake. Definitely going to pay closer attention in future posts. I'll leave it there as "food for thought". For the OP: have you considered using a sparse representation for your polynomials? Something along the lines of (degree, coefficient) tuples. I don't know a huge amount about symbolic computation, but perhaps a sparser representation may even have some algorithmic advantages too. If you stick with the dense representation, you could probably also eliminate the leading zero coefficients as part of the computation. Some more food for thought.
  2. [font="Courier New"]coeffs.erase( remove_if(coeffs.begin(), coeffs.end(), bind1st(equal_to<T>(), static_cast<T>(0))), coeffs.end());[/font] I think I got that right. I should point out that, in any case, you may want to look into specializing the template for floating-point numbers so that you can use an epsilon-based zero check instead of an equality check. [EDIT] As rip-off's post mentions below, this solution removes all zero coefficients, not just the trailing zeros.
  3. For reading: self._tiles = [line.strip() for line in f]strip() gets rid of the whitespace at both ends of the string, so I'm assuming that the only whitespace is the newline on the right. If there is other whitespace - on either the left or right end - that is important, perhaps you want to replace line.strip() with line[:-1]. For drawing: for yoffset in xrange(len(self._tiles)): self.stdscr.addstr(y + yoffset, x, self._tiles[yoffset]) If the above code is unclear, feel free to ask for clarification. [Edited by - aryx on January 6, 2011 5:03:04 PM]
  4. aryx

    virtual funtions??

    If some of your subclasses don't need to do anything, you can do one of two things:Provide a default implementation in the base class, which can be simply an empty functionProvide an empty implementation in the subclasses.
  5. aryx

    [C++] Templates

    Quote:Original post by Vanderry Hm, okay... So in other words I either can't associate complex functions with classes that hold templated member variables, or I need to put all the defintitions in the header file? Sorry if I'm not getting the point, but I can't help but wonder how STL classes like std::vector work then :/ I'm pretty sure the standard containers have their interface and implementation all in the header file. Also, you actually can separate a templated class into header and implementation files, but you need to explicitly instantiate the template for every type you'll be using. I've done this before. An example: // In templated.hpp template <class T> class Templated { // interface }; // In templated.cpp // Implementation here // Template instantiations template class Templated<int>; template class Templated<double>; I'm far from being an expert, so someone else will have to verify whether or not this works in general, or if it just works for me in GCC. I think it should work in general though, since explicitly instantiating the templates means that the linker will be able to find the the necessary code for any other code that uses those templates. [Edited by - aryx on November 20, 2010 5:42:05 PM]
  6. aryx

    Java: Button Roll Over Effect?

    You'll need to give us more info to really help you. In particular, are you using Swing? AWT? Something else? For example, if you were using JButtons from Swing there is setRolloverIcon and setRolloverEnabled. As the documentation states, you can't necessarily guarantee a look and feel will pay attention to these, in which case you can add a mouse listener. [Edited by - aryx on November 20, 2010 5:13:17 PM]
  7. Are you open to using C++0x stuff? I believe this is also available in Boost somewhere, but static assertions could help: #include <iostream> #include <type_traits> class Base { public: int y; }; class Derived : public Base { public: Derived() { y = 10; } }; template <class T> void foo(const T& bar) { static_assert( std::is_base_of<Base, T>::value && !std::is_same<T, Base>::value, "uh oh!"); std::cout << bar.y; } int main(int, char**) { Base x; Derived y; foo(x); // comment out this line and things will compile foo(y); } If you want to allow Base instances to be passed also, just take out the is_same part of the logical and in the static_assert statement. For me, commenting out foo(x); results in compilable code when running the command g++ -std=c++0x test.cpp. Another option to play with is the curiously recurring template pattern. There could be others besides for that, but I'll leave it to the template experts (i.e., not me).
  8. I don't know ASP, but by the looks of it you need ClientID instead of ID (or both perhaps). [Edited by - aryx on November 19, 2010 1:18:04 PM]
  9. aryx

    Java Image-Handling?

    Quote:Original post by Fuji For future reference for handling tileset and spritesheet Images, would it be a safe assumption that I should use a BufferedImage not typed as an Image in order to access pixel data directly? It seems like getSubImage() is exactly what I'd need! Thanks a lot; I can make some good progress with this information :) You wouldn't want to call getSubImage() in a tight loop (i.e., your rendering loop). If you break your tileset up into an array of all the individual tiles though, that would be fine, since it would only need to happen once for every time the tileset is loaded (which probably won't be too often). Another option is to use drawImage with source x/y/width/height parameters. [Edit] Actually, after reading the documentation, I should point out that getSubImage() isn't quite as bad in a tight loop as what I originally though because it shares the same data array rather than making a copy. Nevertheless, the instantiation of BufferedImages is probably going to have some impact if getSubImage() were called in a tight loop. [Another Edit] This link may be of interest too, although I've never dealt with volatile images before.
  10. I would say it's simply a matter of not being able to guarantee a set of points will actually have "full" pixel coverage. For example, if you were to zoom in then you'll start seeing spaces between points. Why not try D3DPT_LINESTRIP, which will draw a line from each point to the next.
  11. aryx

    Bilateral Filtering

    How are you with implementing Gaussian filtering? In gaussian filtering you have something of this nature for each pixel in your kernel: weight = exp(-(deltax^2 + deltay^2) / sigma^2) Well Bilateral filtering is much the same, except you add a term which is the difference with the center pixel of the kernel: weight = exp(-(deltax^2 + deltay^2) / sigma^2) * exp(-delta_color^2 / color_sigma^2) How you choose to measure color difference is your choice (L1 / L2 norms are kind of common). If you want something even better than bilateral filtering, check out geodesic support weights. I implemented it for my stereo vision research and it gives superior results over adaptive support weights (a bilateral weighting scheme) in most cases.
  12. aryx

    Python programming, help :]

    Use raw_input instead of input. input takes the input and evaluates it as Python code (so in other words, 'Justin' looks like a variable to Python). raw_input simply takes the input and dumps it into a string.
  13. aryx


    Although you haven't shown us what x is, I'm guessing it's declared as float and not float *. If that is indeed the case then fscanf needs pointers to your variables, so you should do something like: fscanf(file,"%f",&x);
  14. aryx

    specular Shader Problem

    Looks like you're missing a parenthesis on line 30: float specularModifier=max(dot(bump, normalize(halfVec), 0.0);
  15. Hmm, that would make sense since anchor elements are inline by default. One possibility is to set display (CSS property) to inline-block for the anchor ("a") element. If you're only targeting newer browsers, this will probably work fine (newer meaning IE8+, FF3+, etc.). Another possibility is to use javascript and work with the onclick event of the main DIV. Finally, the last possibility would be to use a "container" DIV inside the link tag to hold all of the contents, like so: <div class="widget-main"><a><div> ...contents... </div></a></div>. Note that I try these ideas in the latest Chromium, so I don't guarantee things work on all browsers. I'll leave the testing up to you! :-)
  • 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!