Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 10 May 2006
Offline Last Active Sep 07 2013 03:50 PM

#4995494 High-level and Low-level languages.

Posted by on 30 October 2012 - 11:43 AM

Wikipedia is your friend for examples.

At the lowest (reasonable) level, you will have Assembly code.
Slightly higher level you'll have languages like C and Fortran
At a higher, but still low level, you'll have languages like C++ and D
Then higher up, languages like C#, Java
Higher up again you'll get things like Haxe, JS, Python
At probably one of the highest levels, you'll get languages like Prolog, Haskell, Agda

The lower the language is, the more closely it will match the underlying machine architecture, Assembly you're working with mostly individual machine op-codes with a human friendly name. C adds things like named variables, scopes, expressions etc. Once you get to the level of Haskell, you're very well removed from underlying architecture almost all together.

#4987085 Smart way to count positive entries in bitset

Posted by on 05 October 2012 - 06:12 AM

Written in Notepad, it may or may not compile.
Also it's not tested, it may or may not be faster/slower, that's up to you to test.

It's also incorrect, you would need to test against:

0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80.

#4985830 Good math book for trajectories,Trigonometry

Posted by on 01 October 2012 - 01:05 PM

Regarding your last line in particular, you 'can' use trigonometry for that, but it is a very roundabout way of doing things. Such things use linear algebra instead, specifically simple vector mathematics.

#4955422 Separating axis 3d

Posted by on 03 July 2012 - 01:35 PM

SAT in 3D is nearly the same as in 2D but with extra axis that you may not think of that must be checked.

For two polyhedra, you have (as expected) the face normals as potential seperating axis, but you also have all cross products of edges (one from one polyedra, one from the other) as potential axis. (Being careful not to check degenerate axis) which clearly paves the way for some numerical issues as well as meaning the number of seperating axis can quickly explode!

In 3D you may more commonly see the more general (and fairly easy to implement in a numerical stable way) GJK algorithm for intersection tests between 'any' two convex shapes rather than strictly defined primitives. It's usual partner is the EPA algorithm if you need to find more information than 'they are colliding' for intersecting shapes which is unfortunately much harder to implement in a numerically robust way.

#4943201 SPH paper...notation issues.

Posted by on 25 May 2012 - 05:51 AM

Your interpretatino of (20) is correct.

Del operator is the gradient, and (15) computes a scalar yes, but the del of that equation is a vector:

If you have a function F : R^3 -> R
then del F : R^3 -> R^3, del F = [ p/px F, p/py F, p/pz F ] as the vector of partial derivatives of F.

#4912566 Sorting some numbers...kind of

Posted by on 13 February 2012 - 06:47 AM

Thanks for your reply, but I think you misunderstood.
I don't want the indexes to change at all. I want to simply output the numbers directly in order.
Because, when I use the sorted list, the indexes aren't the same... Get me?
I need each index to have their specific number.
I have a feeling recursion might be useful for this, but I can't come up with anything.

I still don't see how sorting a copy won't work. If all you want is to output the numbers in order, how can you not sort a copy of the list and output it? The values come out in order, and the list is unchanged. Those are the only two requirements I can find in your posts.

He wants for instance:

[1, 6, 2, 4]

to be 'outputted' like:

[1 (index 0), 2 (index 2), 4 (index 3), 6 (index 1)]

#4899429 Directional vector question

Posted by on 03 January 2012 - 05:23 PM

You can do this very simply with a perp-dot product.

Given the object to be queried at 'b' and the object where you are standing 'a' and direction 'd', you compute

(b-a) perpdot d

and check the sign of the value.

perpdot between two vectors (x1,y1) and (x2,y2) is x1*y2 - y1*x2

#4896791 LaTex test post

Posted by on 23 December 2011 - 05:39 AM

What are the chances of getting extra packages? :)

#4891057 is it possible to check if 2 vectors are criss crossing?

Posted by on 06 December 2011 - 04:27 AM

If you take the two line segments as rays (a + tu) and (b + sv) for t,s in [0,1] (aka given line x1 to x2, the ray is x1 + t(x2-x1)) then you can compute:

I'm having a little trouble visualizing your variables. Would it be too much trouble to request a diagram?:)


line segments defiend by the points a,b and vectors u,v such that the end points are a + u, and b + v and any point on the two line segments can be defined by a + tu, b + tv where u,v in [0,1]
To find t, we search the point a + tu, such that (a+tu-b) perpdot v = 0. perpdot is 0 when two vectors are parallel, so looking at the diagram, the perpdot is zero when the red point is at the intersection of the infinite lines containing the segments, where the blue vector is parallel with 'v'.

Working it the other way, you get the value for s in b + sv for the intersection, and by checking both t,s are in [0,1] you know the intersection occurs on the line segments <=> the line segments intersect

#4886812 Passing by reference or by pointer

Posted by on 23 November 2011 - 01:14 AM

I reverse engineered the 2 binaries and compared them...

You realise compilers can be instructed to output assembly themselves?

#4886500 aprox. volume of box to box intersection

Posted by on 22 November 2011 - 05:05 AM

If you're going to use spheres then you can compute the intersection volume exactly without an algorithm.

real sphere2sphere(sphere c1, sphere c2) {
    vec delta = c2.pos - c1.pos;
    real cr = c1.rad + c2.rad;
    real ds = dot(delta,delta);
    if(ds > cr*cr) return 0; //not intersecting
    elif(ds < eps) return min(volume(c1.rad),volume(c2.rad)); //special case equal position (stability)
    else {
        real d = sqrt(ds);
        real x1 = 0.5*(d - (c2.rad*c2.rad - c1.rad*c1.rad)/d);
        real x2 = d - x1;
        if  (x1<=-c1.rad) return volume(c1.rad); //total containment
        elif(x2<=-c2.rad) return volume(c2.rad); //total containment
        else return cap_volume(x1,c1.rad) + cap_volume(x2,c2.rad);

real cap_volume(real x, real r) {
    real h = r-x;
    return pi*h*h*(3*r-h)/3;
real volume(real r) return cap_volume(-r,r);

#4882526 biliinear interpolation

Posted by on 10 November 2011 - 05:17 AM

Does this give you a strong enough hint?

#4876452 Broadphase for segments

Posted by on 24 October 2011 - 02:18 PM

Why not use the Bentley-ottmann algorithm? This is an O((n+k).log(n)) algorithm (k intersections, n segments) for finding all intersections between a soup of segments

#4874611 Reducing quadratic equation (a=1)

Posted by on 20 October 2011 - 02:31 AM

Do you have a source for that, because quite simply it is wrong.

#4865848 Visualization vs Graphics

Posted by on 25 September 2011 - 02:35 PM

visualisation 'uses' graphics to convey information.
topology and geometry are different fields of mathematics. geometry about the properties of points, and lines and curves etc. topology about properties invariant under continuous transformations (not necessarly geometrical transformations nor of geometry)