• Content count

  • Joined

  • Last visited

Community Reputation

109 Neutral

About pantaloons

  • Rank
  1. The easiest way to do this in my view is with cURL and Firefox Live HTTP headers. Should be a two step process: 1. Log in to the router. (Assuming it uses cookies, POST) [code]curl -c cookie.jar -F "user=myuser;pass=mypass"[/code] 2. Post to the port forwarding POST handler [code]curl -b cookie.jar -F "port=1111;dest=;opt1=0;opt2=0"[/code] Obviously the parameter names, post handlers (or) update method(s) will be different and this is what you need to view headers for. Some pages have simple bot detection, which may require setting the user agent and referer headers (sometimes others like expect-100 continue...).
  2. At a glance the code looks to be OK, if you can find the loop which is not terminating it would be significantly easier to debug. On a related note though, the set cover problem is NP-complete, the algorithm this code implements is an approximation algorithm; it will not be correct in general. If you need to find the correct answer and not an approximation, assuming the the universe is typically small (<20) you should be able to get away with an exhaustive backtracking algorithm, for slightly higher bounds there are nice reductions to knapsack which may perform a little bit better. In the context of skill selection which you seem to have, I'm curious how set cover arises. Are you sure you do not want the exact cover problem?
  3. Let the original triangle be (a, b, c) -- the desired triangle (A, B, C). You want a transformation matrix [code] | m1 m2 m3 m4 | M = | m5 m6 m7 m8 | | m9 m10 m11 m12 | | 0 0 0 1 |[/code] such that M*a = A, M*b = B, M*c = C. This gives 9 equations and 12 unknowns (the system is under determined (in fact you need four points to uniquely specify an affine transformation in 3-space) unless the source points are collinear and the destination points are either not collinear or collinear and not spaced proportionally in which case the matrix will be singular). You should be able to construct this system and pick an arbitrary solution.
  4. normals and how to filter them?

    I don't quite understand what you are trying to do. You have sampled the normals of a "cube-like" shape at a variety of points and filtered them out by the angle they make with the vector (1, 0, 0) -- could you perhaps draw a picture? [quote][color="#1C2837"][size="2"]stated to only include those between 80 and 100 degrees (or equivalent in radians).[/size][/color][/quote] Between 80 and 100 degrees from what? The vector (1, 0, 0) would be the normal of the yz plane -- the vectors which have angle 80-100 to this is essentially the exterior of an x oriented conical surface with a rather wide aperture.
  5. [quote name='quasar3d' timestamp='1321960175' post='4886501'] [quote name='pantaloons' timestamp='1321589503' post='4885211'] [quote name='Vexator' timestamp='1321566918' post='4885127'] I have an arbitrary number of points which are all located on a plane in 3D space. I need to find the four corner points of the rectangle which tightly encloses all points. how can i do that? thank you! [/quote] "Tightly encloses" is ill-defined. If you mean the rectangle with minimal area, this is called the minimal enclosing rectangle problem and can be solved in linear time. See [url=""][/url] For other definitions of "tightly encloses" it may be significantly easier or significantly harder. [/quote] Are you sure it can be solved in linear time? The link you posted only seems to solve it in linear time for convex polygons. I can't really think of quick way to prove that it's not possible in linear time for an arbitary set of points, but I have a suspicion that its not possible. [/quote] You are right, its loglinear for nonconvex polygons. Any algorithm which enumerates the convex hull trivially cannot be linear time.
  6. [quote name='Acef' timestamp='1321426129' post='4884469'] [color="#1C2837"][size="2"]I've decide to specifically use this RSA library because its exactly what the server uses.[/size][/color] [/quote] If this is for education purposes that is fine, but if you are going to going to use the converted code in the "real world" I would perhaps rethink this decision. The RSA algorithm itself does not change, up to wire protocols, padding schemes, and so on. These are completely specified by secure protocols (i.e.: TLS/SSL) so all (correct) implementations will be consistent. To that end you should not run into much trouble using an existing cypto library to communicate with this software, certainly nowhere near as much as you will with a hand made one. What's more; there is absolutely no chance at all your RSA implementation will be correct. To answer your actual question, that behavior would be expected if the exponentiation was not being modulated correctly. You may like to investigate the results of "z->mulTo(r2,g,r);" and in particular the reduce methods of the reduction implementations to determine if they are behaving correctly.
  7. [quote name='Vexator' timestamp='1321566918' post='4885127'] I have an arbitrary number of points which are all located on a plane in 3D space. I need to find the four corner points of the rectangle which tightly encloses all points. how can i do that? thank you! [/quote] "Tightly encloses" is ill-defined. If you mean the rectangle with minimal area, this is called the minimal enclosing rectangle problem and can be solved in linear time. See [url=""][/url] For other definitions of "tightly encloses" it may be significantly easier or significantly harder.
  8. Rotating an offset vector to point at a position

    It should have been: [color="#1C2837"][size="2"]omega = pi - theta - phi - beta[/size][/color] [color="#1C2837"][size="2"]If you didn't catch that. Although you are right I think quadrant issues get in the way with the right triangle approach to computing Vr. We can make it easier:[/size][/color] [color="#1C2837"][size="2"]theta = angle between V, D (given)[/size][/color][color="#1C2837"][size="2"][left]||P - Z|| / sin(theta) = ||V|| / sin(phi)[/left][left]phi = arcsin(sin(theta) * ||V|| / ||P - Z||)[/left][/size][/color][color="#1C2837"][size="2"]omega = pi - theta - phi[/size][/color] [color="#1C2837"][size="2"][left]X = (Z - P)/||Z - P||[/left][/size][/color][color="#1C2837"][size="2"]if(0 <= theta <= pi) [/size][/color][color="#1C2837"][size="2"]Vr = ||V|| * R(omega) * X[/size][/color] [color="#1C2837"][size="2"]else Vr = ||V|| * R(-omega) * X[/size][/color] [color="#1C2837"][size="2"][left] [/left][/size][/color] [color="#1C2837"][size="2"][left]Where R(omega) is a standard 2x2 rotation matrix through angle omega. Notice that in fact, discounting the direction of vector D, there are two solutions that are equally rotated away from the vector Z - P, however you want the solution where D points towards Z which necessitates a negative rotation if -pi < theta < 0 (or turn(P, V, D) == right)).[/left][/size][/color]
  9. Rotating an offset vector to point at a position

    [quote name='SodiumEyes' timestamp='1320546693' post='4880953'] This is something I can't seem to figure out: [attachment=5990:problem.png] I have two 2D points P and Z, and two 2D vectors V and D. I need to find a rotation angle a such that Z lies on a line with the origin P+V[sup]R[/sup] and direction D[sup]R [/sup]where V[sup]R [/sup]is V rotated by a and the same for D. Note that D doesn't have to be a vector, it can be an angle if that makes it easier. I'd appreciate any help on this issue. [/quote] Here's a crack at it, untested and could be completely wrong theta = angle between V, D (given) ||P - Z|| / sin(theta) = ||V - P|| / sin(phi) phi = arcsin(sin(theta) * ||V - P|| / ||P - Z||) beta = arctan((Zy - Py)/(Zx - Px)) omega = 2 * pi - theta - phi - beta Vr.x = ||V - P|| * cos(omega) Vr.y = ||V - P|| * sin(omega)
  10. Simple Client-Server Question

    [quote name='hplus0603' timestamp='1320342637' post='4880199'] On a higher level, you can do it that way. Or you can simulate backwards in time. Or you can run the client ahead of server time. In every case, there is a trade-off between the client not having all information, and the client having high command latency. [/quote] What exactly is the trade off when doing backwards simulation? My understanding is that there will be no command latency, and the available information will be at worst as stale as any other model.
  11. Time limited computation

    When in doubt look to the experts. This is last years winner, [url=""][/url] Of note are the functions: [code]_alrm_handler(sig) { _timed_out=true; } int main(int argc, char **argv) {... signal(SIGALRM, _alrm_handler); ... }[/code] He looks to be using some form of minimax, namely: [code]_alphabeta(...) { ... for (int _m=-1;_m<4 && !_timed_out;_m++) { ... _alphabeta(...); ... } ... }[/code]
  12. Let the Bezier control points be [font="CourierNew, monospace"](x0, y0), (x1, y1), (x2, y2). W[/font][font="CourierNew, monospace"]e wish to find the intersection of points that are a distance r[/font][font="CourierNew, monospace"] from (x0, y0).[/font][font="CourierNew, monospace"] In other words, the intersection of the circle (x - x0)^2 + (y - y0)^2 = r^2 [/font][font="CourierNew, monospace"]with the curve ((1 - t)^2 * x0 + 2(1 - t)t * x1 + t^2 * x2, [/font][font="CourierNew, monospace"](1 - t)^2 * y0 + 2(1 - t)t * y1 + t^2 * y2), 0 <= t <= 1.[/font][font="CourierNew, monospace"] [/font] [font="CourierNew, monospace"]Substituting this in,[/font][font="CourierNew, monospace"] [/font] [font="CourierNew, monospace"]([/font][font="CourierNew, monospace"](1 - t)^2 * x0 + 2(1 - t)t * x1 + t^2 * x2 - x0)^2 + ([/font][font="CourierNew, monospace"](1 - t)^2 * y0 + 2(1 - t)t * y1 + t^2 * y2 - y0)^2 = r^2[/font] [font="CourierNew, monospace"] [/font] [font="CourierNew, monospace"]Solving for t will give you a quartic, (The 0 <= t <= 1 constraint actually means there are at most three valid solutions I believe, although I'm not sure if there is an easier way to solve such a special case) -- you can solve the quartic exactly although this is probably not a great idea.[/font] Much easier would be to apply newtons method etc.
  13. Intersecting two angular ranges

    Quite right -- it's a rather fiddly problem although my general view is an arithmetic moduli solution will be cleaner in the end than any hull type solution (see below). I'll try one more time, if I were writing this for work etc I may just write a brute force test for all integer 4-tuples to ensure it is probably correct and easily debug failing cases, hopefully you get the idea of how the solution *might* be constructed. [code]pair<int, int> intersect(pair<int, int> range1, pair<int, int> range2) { int min1 = range1.first; int min2 = range2.first; int max1 = range1.second; int max2 = range2.second; if(max1 < min1 && max2 < min2) { max1 += 360; max2 += 360; } else if(max1 < min1) { if(min1 > max2) min1 -= 360; else max1 += 360; } else if(max2 < min2) { if(min2 > max1) min1 -= 360; else max1 += 360; } int min = max(min1, min2); int max = min(max1, max2); if(max < min) return make_pair(-1, -1); // No intersection if(max > 360) max -= 360; if(min < 0) min += 360; return make_pair(min, max); }[/code] Perhaps another possibility similar to yours is to sort the four angles. Denote them [minA, maxA], [minB, maxB]. Walk the sorted angles, if you encounter the pattern "minX maxX minY maxY" then the ranges do not intersect. If you have "minX minY maxY maxX" the range is [minY maxY] and if you have "minX minY maxX maxY" the range is [minY maxX]. As a bonus "minX maxY minY maxX" corresponds to two ranges [minX maxY] + [minY maxX].
  14. Bounding Interval Hierarchy

    [quote name='SG23' timestamp='1319188423' post='4874983'] However, what did you mean by a "triangle level" ? As far as I understood from the paper, the elements can be anything, they only require an aabb. Hence the subdivision process should not even know the elements have any triangles. [/quote] Sure, it doesn't particularly matter what the leaf nodes are. In general it is sensible to use triangles (or small groups of triangles), otherwise your work is for nothing. You could perform a traversal of the bounding hierarchy and still need to perform further intersection tests against whole objects. They are obviously splitting to triangle level here (at least in these images). The right element, (you mean right three triangles?) first gets split horizontally. The bottom triangle is largely below the splitting plane so it gets put in that half, and the other two are mostly above so they go on top. The top quadrant is still not fully divided (it has two triangles assigned now) so is again split, this time vertically with the two triangles going in the left and right halves respectively. This is indicated by the edge colours, red: left child, blue: right child.
  15. Bounding Interval Hierarchy

    Just skimming the paper, it looks to me like that sentence is talking about the case where the entire object resides on one side of the splitting plane. In that case, the space is only recursively divided on the side of the plane which contains the object(s). In figure 3b, the top left quadrant has been split vertically and the right side left empty because the AABB for the child triangles are completely contained in the left partition. As for why they subdivide the right half in 3b, this is expected as the BVH presumably splits the space down to triangle level granularity, not object level. (Generally a subdivision algorithm will split objects up to the point where it becomes less efficient that just doing multiple triangle/ray intersections). I haven't read the paper fully so this could be completely wrong - let me know.