• What are you working on? v19
    6,590 replies, posted
[QUOTE=Vbits;31564917]It really surprises me on how easy to write a packet capture application, although I am really happy I started using a binary writer instead of flat files, though the format is really hard to read right now.[/QUOTE] [URL="http://pastie.org/private/ozyficzlhqkg3bturp6ifq"]It's much cooler if you make one in node.js[/URL]
20 minutes later and i now have a GUI with hex-dumps, the question now, what is a good use for raw network traffic, aside from the obvious uses.
[QUOTE=Vbits;31565102]20 minutes later and i now have a GUI with hex-dumps, the question now, what is a good use for raw network traffic, aside from the obvious uses.[/QUOTE] Make a graph of something with the data. Everyone loves graphs.
[img]http://dl.dropbox.com/u/2014606/nice_flower.png[/img] Blame mr nice flower on youtube, what you see here is one or 2 youtube videos. The graph it's self is generated by plotting the data lengths using a radar graph
Made something that draws pseudo-3D cubes (With rotation and yaw(if that's the correct word)), and now I'm trying to draw more than 1 at the same time. [img]http://i.imgur.com/1WAxL.gif[/img] Not working out so well currently.
I need a working line-line intersection algorithm. I found one on this page [url]http://flassari.is/2008/11/line-line-intersection-in-cplusplus/[/url] but for some reason it doesn't always work: [quote][img]http://img853.imageshack.us/img853/5404/lineintersection.png[/img][/quote] [code]Point* intersection(Point p1, Point p2, Point p3, Point p4) { // Store the values for fast access and easy // equations-to-code conversion float x1 = p1.x, x2 = p2.x, x3 = p3.x, x4 = p4.x; float y1 = p1.y, y2 = p2.y, y3 = p3.y, y4 = p4.y; float d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4); // If d is zero, there is no intersection if (d == 0) return NULL; // Get the x and y float pre = (x1*y2 - y1*x2), post = (x3*y4 - y3*x4); float x = ( pre * (x3 - x4) - (x1 - x2) * post ) / d; float y = ( pre * (y3 - y4) - (y1 - y2) * post ) / d; // Check if the x and y coordinates are within both lines if ( x < min(x1, x2) || x > max(x1, x2) || x < min(x3, x4) || x > max(x3, x4) ) return NULL; if ( y < min(y1, y2) || y > max(y1, y2) || y < min(y3, y4) || y > max(y3, y4) ) return NULL; // Return the point of intersection Point* ret = new Point(); ret->x = x; ret->y = y; return ret; }[/code] There is some guy mentioning "floating point rounding errors" but I don't understand what is he talking about. He added epsilon there...
[QUOTE=AntonioR;31565677]There is some guy mentioning "floating point rounding errors" but I don't understand what is he talking about. He added epsilon there...[/QUOTE] Floating point numbers can't store all possible numbers in the number of bits they have - so they get truncated. So, for example, 0.1 in decimal is approximately 0.000110011 in binary, but not exactly. It has an infinite expansion in binary. And, when you start adding\subtracting\other mathematical operations on these 'approximate' floats, you get further and further away from the value you want. That's why you might have a and b, both "equal to" 0.1, but if you do "a == b" you'll get false. (that example won't work if you set them both to 0.1 then compare them, it's once you've done a series of operations and they're both supposed to be equal to the same thing, but they aren't) The way around that is using an epsilon - a 'fudge factor' I guess you could call it. [cpp] if(abs(a - b) < epsilon) // they're close enough to be equal [/cpp] [editline]6th August 2011[/editline] In summary [cpp] double a; double b; if(a == b) // BAD if(abs(a - b) < 0.1) // they're pretty close if(abs(a - b) < 0.001) // they're much closer [/cpp] [/shittyexample]
[QUOTE=Maurice;31565562]Made something that draws pseudo-3D cubes (With rotation and yaw(if that's the correct word)), and now I'm trying to draw more than 1 at the same time. [img]http://i.imgur.com/1WAxL.gif[/img] Not working out so well currently.[/QUOTE] I could stare at this for hours.
[QUOTE=Maurice;31565562]Made something that draws pseudo-3D cubes (With rotation and yaw(if that's the correct word)), and now I'm trying to draw more than 1 at the same time. [img]http://i.imgur.com/1WAxL.gif[/img] Not working out so well currently.[/QUOTE] I got an issue like that when I was rendering in OpenGL without the depth buffer turned on. I assume you're not using OpenGL, so you'll have to work it out yourself. but you'll need to calculate the approximate 'distance' to the cubes from the camera\viewer, and then render them from furthest away to closest. As it stands at the moment, I assume you're just rendering them in the same order all the time, hence why one cube is always in front of everything and one is always behind everything.
[QUOTE=Maurice;31565562]Made something that draws pseudo-3D cubes (With rotation and yaw(if that's the correct word)), and now I'm trying to draw more than 1 at the same time. [IMG]http://i.imgur.com/1WAxL.gif[/IMG] Not working out so well currently.[/QUOTE] Looks like you just gotta sort your draw order using some sort of depth value for each vertex/cube/whatever. I like how that looks though, it's kinda funny lookin'
[QUOTE=Chris220;31565804]Looks like you just gotta sort your draw order using some sort of depth value for each vertex/cube/whatever. I like how that looks though, it's kinda funny lookin'[/QUOTE] Yeah the drawing order isn't managed at all currently, but the main problem is the positioning of the cubes. I was trying to make them into a plane. [img]http://i.imgur.com/XR3xz.gif[/img] Yay. Pseudo 3D. [img]http://i.imgur.com/D6Ix9.png[/img] Terrible FPS (120), and nothing I can do about it. Well I guess I could check what faces not to draw, but meh. Last update for now! (Because I know you wanna get back to arguing with null and that other guy!) [img]http://i.imgur.com/ExNC3.gif[/img] Newest 3D technology without depth! Oh right, those grey lines are actually not a bug but a feature! I can easily leave them out. [img]http://i.imgur.com/RVjfb.png[/img]
[QUOTE=Maurice;31566301]Yeah the drawing order isn't managed at all currently, but the main problem is the positioning of the cubes. I was trying to make them into a plane. [img]http://i.imgur.com/XR3xz.gif[/img] Yay. Pseudo 3D.[/QUOTE] Just sort them before drawing by the Y value they will be drawn at. Lowest value first
[QUOTE=tanraga;31564118]C# is fast, but for tight loops with heavy arithmetic (like you seem to be doing), you might find it's faster to write a native DLL and P/Invoke across to it. When I rewrote the number-crunching part of my [url=http://i.imgur.com/ICq02.gif]Facepunch cube[/url] in C, I noticed a dramatic performance increase.[/QUOTE] He could stay entirely in .NET and write the loops in F# while using recursion :v: (Note: F# is amazing, and it's getting used a lot now by .NET shops. Also DSLs all up in this bitch)
[QUOTE=AntonioR;31565677]I need a working line-line intersection algorithm. I found one on this page [url]http://flassari.is/2008/11/line-line-intersection-in-cplusplus/[/url] but for some reason it doesn't always work: [code]Point* intersection(Point p1, Point p2, Point p3, Point p4) { // Store the values for fast access and easy // equations-to-code conversion float x1 = p1.x, x2 = p2.x, x3 = p3.x, x4 = p4.x; float y1 = p1.y, y2 = p2.y, y3 = p3.y, y4 = p4.y; float d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4); // If d is zero, there is no intersection if (d == 0) return NULL; // Get the x and y float pre = (x1*y2 - y1*x2), post = (x3*y4 - y3*x4); float x = ( pre * (x3 - x4) - (x1 - x2) * post ) / d; float y = ( pre * (y3 - y4) - (y1 - y2) * post ) / d; // Check if the x and y coordinates are within both lines if ( x < min(x1, x2) || x > max(x1, x2) || x < min(x3, x4) || x > max(x3, x4) ) return NULL; if ( y < min(y1, y2) || y > max(y1, y2) || y < min(y3, y4) || y > max(y3, y4) ) return NULL; // Return the point of intersection Point* ret = new Point(); ret->x = x; ret->y = y; return ret; }[/code] There is some guy mentioning "floating point rounding errors" but I don't understand what is he talking about. He added epsilon there...[/QUOTE] There is another way to express the final solution to the intersection equation that I found better Basically the intersection is achieved by solving a and b out of the equation [img]http://latex.codecogs.com/gif.latex?\overrightarrow{p}%20=%20\overrightarrow{s_0}%20+%20a%20(\overrightarrow{e_0}%20-%20\overrightarrow{s_0})%20=%20\overrightarrow{s_1}%20+%20b%20(\overrightarrow{e_1}%20-%20\overrightarrow{s_1})[/img] The lines intersect if there are solutions (i.e. you don't end up with divisions by zero or other illegal things), and the line segments intersect if there are solutions for a and b that are between 0 and 1. This site explains the programming bit better: [url]http://paulbourke.net/geometry/lineline2d/[/url]
I was trying to recreate this: [url]http://weegen.home.xs4all.nl/eelis/analogliterals.xhtml[/url]. My attempt, only 1D and 2D:[cpp]#include <iostream> using namespace std; class analogI { public: analogI() : val(0), mul(0) { } analogI(int newval, int newmul = 0) : val(newval), mul(newmul) { } analogI operator *() const { return analogI(val + 1); } analogI operator *(const analogI b) const { if (mul == 0) return analogI(b.val + 1); else return analogI((b.val + 1) * ((mul + 1) / 2)); } analogI operator !() const { return analogI(val, mul + 1); } analogI operator |(const analogI b) const { return b.val; } operator int() { return val; } private: int val; int mul; } I; int main() { int num = I***I; int num2 = I*******I; int num3 = I***I | ! ! ! I***I; int num4 = I*****I | ! ! ! ! ! ! ! ! ! I*****I; cout << num << endl; cout << num2 << endl; cout << num3 << endl; cout << num4 << endl; return 0; } [/cpp]
Tried ODE for fun but I'm not going to use it for my project. [img]http://i51.tinypic.com/20i9ceg.gif[/img]
[QUOTE=thelinx;31563489]chats logs[/QUOTE] What about them?
[QUOTE=AntonioR;31565677]I need a working line-line intersection algorithm. I found one on this page [url]http://flassari.is/2008/11/line-line-intersection-in-cplusplus/[/url] but for some reason it doesn't always work: [code]Point* intersection(Point p1, Point p2, Point p3, Point p4) { // Store the values for fast access and easy // equations-to-code conversion float x1 = p1.x, x2 = p2.x, x3 = p3.x, x4 = p4.x; float y1 = p1.y, y2 = p2.y, y3 = p3.y, y4 = p4.y; float d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4); // If d is zero, there is no intersection if (d == 0) return NULL; // Get the x and y float pre = (x1*y2 - y1*x2), post = (x3*y4 - y3*x4); float x = ( pre * (x3 - x4) - (x1 - x2) * post ) / d; float y = ( pre * (y3 - y4) - (y1 - y2) * post ) / d; // Check if the x and y coordinates are within both lines if ( x < min(x1, x2) || x > max(x1, x2) || x < min(x3, x4) || x > max(x3, x4) ) return NULL; if ( y < min(y1, y2) || y > max(y1, y2) || y < min(y3, y4) || y > max(y3, y4) ) return NULL; // Return the point of intersection Point* ret = new Point(); ret->x = x; ret->y = y; return ret; }[/code] There is some guy mentioning "floating point rounding errors" but I don't understand what is he talking about. He added epsilon there...[/QUOTE] I wrote a solution using ThePuska's method for if you're stuck. [cpp]#include <iostream> class vec2 { public: vec2() : x( 0 ), y( 0 ) {} vec2( float x, float y ) { this->x = x; this->y = y; } vec2 operator*( float n ) const { return vec2( x*n, y*n ); } vec2 operator-( const vec2& b ) const { return vec2( x-b.x, y-b.y ); } vec2 operator+( const vec2& b ) const { return vec2( x+b.x, y+b.y ); } vec2 operator-() const { return vec2( -x, -y ); } float x, y; }; bool intersectLines( const vec2& p1, const vec2& p2, const vec2& p3, const vec2& p4, vec2& intersection ) { vec2 d1 = p2-p1; vec2 d2 = p4-p3; vec2 d3 = p1-p3; float d, a, b = d1.x/d1.y; if ( p1.y == p2.y ) b = ( p1.y - p3.y ) / ( p4.y - p3.y ); else b = ( d3.x - d3.y * d1.x/d1.y ) / ( d2.x - d2.y * d1.x/d1.y ); a = ( p3.x + d2.x * b - p1.x ) / d2.x; if ( b < 0 || b > 1 || a < 0 || b > 1 ) return false; intersection = p3 + (p4-p3) * b; return true; } int main() { vec2 result; bool success = intersectLines( vec2( -2, 4 ), vec2( 3, -3 ), vec2( -1, -3 ), vec2( 3, -1 ), result ); std::cout << std::boolalpha << success << " -> ( " << result.x << ", " << result.y << " )" << std::endl; return 0; }[/cpp]
[QUOTE=i300;31569833]What about them?[/QUOTE] I'm assuming he's asking if chat logs are saved
[QUOTE=Quark:;31570615]I'm assuming he's asking if chat logs are saved[/QUOTE] Yeah duh. They're saved to your iPhone inside the app bundle. I forgot to make an export feature (packages each one up in a .TXT format and bundles them into a zip. Then you can email it to whoever I guess.). I am going to work on that now.
[QUOTE=Chandler;31567199]He could stay entirely in .NET and write the loops in F# while using recursion :v: (Note: F# is amazing, and it's getting used a lot now by .NET shops. Also DSLs all up in this bitch)[/QUOTE] I was just looking at F#'s performance compared to C#, F# is pretty damn fast: [url]http://abdullin.com/journal/2009/1/6/f-has-better-performance-than-c-in-math.html[/url] It's pretty much as fast as C while still compiling down to IL
[QUOTE=robmaister12;31570737]I was just looking at F#'s performance compared to C#, F# is pretty damn fast: [url]http://abdullin.com/journal/2009/1/6/f-has-better-performance-than-c-in-math.html[/url] It's pretty much as fast as C while still compiling down to IL[/QUOTE] The syntax looks ... interesting
The syntax reminds me of a syntax I made up called biblecode [code] Let there be System; God said: "Hello, World!"; //And there was earth armageddon(); //Or whatever the end of times was called [/code]
[QUOTE=uitham;31571777]The syntax reminds me of a syntax I made up called biblecode [code] Let there be System; God said: "Hello, World!"; //And there was earth rapture(may 21); //Or whatever the end of times was called [/code][/QUOTE] ftfy
[img]http://i.imgur.com/oRWvN.png[/img]
You need to add Deep Space 9 and a wormhole
Still working on my roguelike dungeon generator. Next is corridors. [img]http://img854.imageshack.us/img854/975/dungeon.png[/img]
[QUOTE=robmaister12;31570737]I was just looking at F#'s performance compared to C#, F# is pretty damn fast: [url]http://abdullin.com/journal/2009/1/6/f-has-better-performance-than-c-in-math.html[/url] It's pretty much as fast as C while still compiling down to IL[/QUOTE] That is a terrible speed comparison. If you are going to compare speeds at least use the same freaking loop. [code] for t in 1 .. 10 do for x in 1 .. 1000000 do[/code] vs [code] for (int i = 0; i < 10; i++) for (float x = -5.0f; x < 5.0f; x += 0.000001f)[/code] Changing the loop alone improved the speed greatly. Edit: [img]http://goo.gl/4pdR7[/img] Didn't look into the second method too much. My guess is the speed difference has to do with F# being able to optimize out things that C# can't
[QUOTE=Hypershadsy;31571685]The syntax looks ... interesting[/QUOTE] F#'s syntax is effectively taken from ML (of which OCaml is an implementation), which is a mixed paradigm language, where objects are used, but the primary focus is on the functional programming paradigm. Unlike pure FP languages such as LISP and Haskell, F# and OCaml allow some types to be mutable, and side effects to occur (i.e., if you send an object to a function, there isn't an absolute guarantee that the data within it won't be modified in addition to whatever is the return type) It's a bit strange, but F#'s primary strengths lie in data processing, and parsing, as well as filtering. A lot of the work that went into F# before its release was added into C# over time, such as generics, and LINQ. It's pretty awesome :)
Not exactly the greatest thing in the world, but I've been working on a level editor for the tile-based game I'm working on. [thumb]http://dl.dropbox.com/u/6470891/progress01.png[/thumb] There are three layers; ground, above the player, and collision (represented by the red squares). Everything's tile based and saved to a .txt file, which I'm working on allowing my game to read. Next step is to get entities to load from it, and to load a different map when you step into an area.
Sorry, you need to Log In to post a reply to this thread.