MattEvans 473 Veteran Poster Team Colleague Featured Poster

Also, (I forgot to mention) changing the permissions of a file to anything won't protect you from that kind of attack, since your user account can always change the permissions of your own files; if someone can execute shell ("command line") code, they can just chmod the relevant files to what they want first.

The best way to protect yourself from this kind of thing is, obviously, to use high quality scripts. You can also run scripts with lower priviledges than your own, if you're still worried. Unfortunately, you need to be able to create new user accounts on the server and edit the server config to do that, and most service providers wont allow you to do that with a basic hosting package.

You have checked the obvious right? that your FTP or control panel password hasn't been leaked/stolen/hacked? You should be able to check FTP access logs (look for unknown IPs logging in as you). But, you may only be able to get access to the logs by asking your hosting provider for them, since they'd be global logs (for all customers).

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Scripts are usually chmod 755 ( google it ) so the permissions will be set 'correctly', at least in that no non-priviledged user can edit your files (e.g. an FTP guest). It isn't necessary for the server root password to be compromised for this kind of thing to happen - anyone with your user access can of course modify the files. Since scripts run with the permissions of your user account, that means any executed script on your site can, potentially, edit/delete/create any script/file/folder/config that you can.

The most usual way that this happens is a dodgy script with a security vulnerability.. As a trivial, contrived, example, imagine this being in a PHP script:

exec ($_GET);

and now imagine a user accessing your page with:

http://yourdomain.tld/page.php?somevar=rm%20-rf&

this would politely ask the PHP script (running as your user, remember) to delete all files and folders in the script's current directory. Simple, eh?

Obviously, you won't do something like this deliberately, or something this obviously stupid, but variations on this pattern basically allow someone access to everything that you can access, from a browser, without ever needing your (or anyone elses) password.

Now, do you use some kind of prefab PHP application on your site? Because, it's highly unlikely that the kind of attack I just outlined would occur with home-made code, since no-one would be able to see what the site's code actually does (which then would suggest that maybe someone does

MattEvans 473 Veteran Poster Team Colleague Featured Poster

It's generally frowned upon to hijack existing threads to ask new, unrelated, questions.. so I'll ask a software development mod to split this thread.. In the meantime:

- linux distro?
- graphics card?
- language you are using?

are you absolutely sure opengl isn't installed? most distros usually have installed, at least, the mesa* implementation of opengl. some distros have a graphics card driver config page in the installation.

generally, if you install your graphics card drivers properly, opengl 'just works', since the card drivers for a modern card come with opengl libs.

(* 'mesa' is the name of an implementation of opengl that works completely in software i.e. doesn't depend on an accelerated graphics card).

also see: http://wiki.linuxquestions.org/wiki/OpenGL, avoid following the config steps unless you're sure you know what you're doing, but all means follow the diagnostic steps. in particular, let me know if running 'glxinfo' (in a terminal) outputs anything.

Everytime I follow any of their "readme" for whatever library I want to install, or if I use my OS's package manger, many times make installation will fail.

I've been through a few distros now - namely Mandrake/Mandriva, openSUSE, Debian... I find Debian to be the nicest (of these), in terms of package management.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

So, when you see all your tasks running in memory, it may seem like everything is running at once, but in reality it's not.

Except that 3D graphics is one place where you can work with "genuinely" parallel processes - i.e. a graphics card typically has it's own independant CPU.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Ok, thanks.

Other alternatives meaning, the list I put of things that I could have done to avoid having to do this.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

If I add default arguments to the end of my copy constructor, is it still considered a copy constructor? E.g. will it still be used in the places where a copy constructor would normally be used (or automatically generated).

I can verify that it works on one compiler (g++). That is, this does output the "copy ctor" message 3 times:

#include <iostream>

class Context
{
  // real thing actually has some methods
};

class A
{
  private:
    Context & m_context;

  public:
    A ( Context * context )
      :m_context ( MATT_DEREF ( context ) )
    {
      // probably do something with context here..
    }

    A ( const A & a, Context * new_context = 0 )
      :m_context ( new_context ? *new_context : a.m_context )
    {
      std::cout << "copy ctor\n";
      // probably do something with context here..
    }
};

void test ( A a )
{ return; }

int main ( void )
{
  Context c1, c2;
  A a1 ( &c1 );
  // implictly copying by passing as value
  test ( a1 );
  // explicitly copying in the same context
  A a2 ( a1 );
  // copying to a new context
  A a3 ( a1, &c2 );
  return EXIT_SUCCESS;
}

But, will this always work O.K.? are there any caveats/pitfalls etc?

Other alternatives considered:

- I can't have the generated copy ctor used, for various reasons (e.g. other pointers/reference members shouldn't be shallow copied ).
- I don't want to pass the pointer to "context" in later, …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

jbennet doesn't have edit permissions in this forum (neither do I). We don't all moderate all forums.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Please post all of the "undefined reference" errors.

Did you get a different error when you tried with -lgmp?

You are using GMP, yes?

If so, did you compile GMP yourself, or use a packaged version?

MattEvans 473 Veteran Poster Team Colleague Featured Poster

I assume you're including headers from the gnu multiple precision library?

If so you need to tell the linker the name of the library.. e.g.

gcc multiply1.c -lgmp

If that doesn't work.. make sure you have the library installed and in one of the "normal" library directories.. If it's not in one of the normal directories:

gcc multiply1.c -lgmp -L/directory/name/here
MattEvans 473 Veteran Poster Team Colleague Featured Poster

jb, have you ever considered a career in telesales?

XD

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Also, if you have a mismatch between the number of items you say are in the array, and the number of items you actually put in the array, you'll get an error that says something along the lines of "too many initializers".

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Post the full line of code where you get the error.

But, it looks like you have the double quote and comma in the wrong order in that excerpt.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

The nicest solution (in terms of future flexibility), is to encode your data in either a bitmap image or a text file.

Alternatively, if you just want to initialize an array of arrays:

// made smaller (4x4) so it fits in a post neatly...
string MAP[4][4] = {
{"|I|", "|I|", "|I|", "|I|" },
{"|I|", "|I|", "|I|", "|I|" },
{"|I|", "|I|", "|I|", "|I|" },
{"|I|", "|I|", "|I|", "|I|" }
};

But you're right, you can't initialize one 'row' at a time. It has to be done all at once.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

That "the behaviour when dereferencing an invalid pointer is undefined" is fact.

Other than that, the best you'll get (in terms of an explanation for why you get this output) is speculation or some implementation-specific reason. On my implementation (GCC) reasonable evidence (see second code I posted) suggests that local variables in any function get allocated from the same starting address (assuming the calls come from the same level).

(EDIT: and that would be sufficient explanation for your output, providing std::ostream::operator<< allocates at least one local variable)

There's no requirement for "reclaimed" memory to be zeroed or otherwise restored (by reclaimed, I mean memory under deleted pointers or under auto variables that go out of scope). The most efficient implementation strategy is to just leave the contents of such memory untouched, hence, before reclaimed memory is overwritten, it will tend to contain its old value. (You shouldn't rely on this, either)

Nick Evan commented: Excellent posts in this thread! +12
MattEvans 473 Veteran Poster Team Colleague Featured Poster

The behaviour when dereferencing an invalid pointer is undefined. So I can only speculate on the underlying reason: it probably has to do with how and where stack variables are allocated, e.g. sequential function calls within a given scope might allocate stack variables from the same starting place, so stuff that's stack-allocated in the first call to cout << is likely to overwrite anything that was stack allocated on the prior call to treble. When it's done all in one call to cout <<, the value is fetched back before calling any other function, and thus before it's likely for it to have been overwritten, and it appears to work ok.

You can occasionaly predict how the thing is going to behave, e.g., I was pretty sure that this would happen:

double num = 5.0;
double* ptr = 0;
ptr = treble(num);
treble( 2.0 );
cout << endl << "Three times num = " << 3.0*num << endl << "Result = " << *ptr;

Outputs:
Three times num = 15
Result = 6

On my machine, but I wouldn't bet on it being the same as yours, and I'd never rely on it working like that on mine.

A clearer example:

#include <iostream>

int fn_a ( void )
{
  int a = 0;
  std::cerr << &a << std::endl;
}

int fn_b ( void )
{
  int b = 0;
  std::cerr << &b << std::endl;
}

int main ( void )
{
  fn_a ( …
MattEvans 473 Veteran Poster Team Colleague Featured Poster

You don't imply any memory management in the description of the problem: there's no necessity that the nodes/lists even be allocated with new, e.g.:

Node a, b;
a.next = &b;

You wouldn't want any automatic delete to occur in this case, since you never call new ( a and b will be correctly de-allocated when they leave scope). If you can get away with allocating everything you need up-front and then deleting it when its no longer needed (or by not calling new atall as above), then do it that way.

If you must assume that one object 'owns' another, and your sure that all objects are allocated with new, then have have node's destructor delete the node pointed to as 'next' and its own vertex list node, and have each vertex list node delete its 'next' vertex node on destruction. Then call delete on only the first node. That is assuming that any given VNode is only reachable from a single Node, is that a correct assumption?

but it seems like a lot to make two separate list classes just to run on program.

This is why we generally use std::list / std::vector / etc.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

That's pretty much the same as using an std::basic_string<uchar>; the only reason I didn't suggest it because I wasn't sure off the top of my head whether std::vector<T> provides a useful implementation of operator<.. but, a quick check reveals that it does (it's a lexicographic compare, just like std::basic_string<T> ), so that'll work just as well.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Well, since arrays deteriorate into pointers to the first element, you could go with:

map<unsigned char*, int> ColorList;

If you use this code though, the map will end up containing invalid pointers unless the lifetime of of the array(s) and the lifetime of the map are the same. Also, the maps comparator function won't work how you want it to, since it will perform pointer compares.

Solutions? Either:
- make a class "Color" which contains the rgb array, and overide operator< ( since this is what a map uses for its ordering ).
- use an std::basic_string<unsigned char> to represent the colour, (if you don't mind the fact that it doesn't have a fixed size).
- use an std::pair<uchar,std::pair<uchar,uchar>> (although that's ugly).
- write a generalized 3-tuple (triple) class, or even a fully generalized (arbitrary sized) tuple class.
- concatenate the uchar elements (by left-shift and binary-or, or by using a non-portable union/cast trick) into a single (32-bit) int, and you have 8bits left over for alpha, and the < comparator is then free, and very fast.

Willing to further explain any of those methods, if necessary.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

You can patent software in the US, but (rightfully!) not in Europe.

Also, there's very little point patenting an entire game, it's too broad, e.g. if you patent a whole game, I'd only have to change a few things to release a very similar but technically non infringing game. You have to be able to write a document which explains, in excrutiating detail, exactly what part/concept the patent covers, and why, and in which circumstances, that part/concept is original.

Instead, you'd generally patent all of the small aspects of the game, so that I couldn't release anything which incorporated those small aspects (without getting prior agreement from you). E.g. you might patent the concept of a "button which when clicked on invokes an action in a program", so that I couldn't use that construct anywhere without your permission.

But, with something like that (and probably most things that you, or even those who actually go so far as to file these things) consider patenting, there's very usually something(s) you've got the idea from, e.g. some prior art. Technically the existance of such prior art should invalidate any subsequent patent application, but there are occasions where they do get granted regardless (with enough jargon & legalese you can make just about anything sound original).

It's quite disgusting, IMHO, since a company can get away with taking legal ownership, and sole licensing rights, of some technique that they never originally developed in the first place, meaning no-one else …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

I have a suggestion with regard to the new style, I don't have time to read every previous suggestion in this thread at the moment, so sorry if it's already been suggested..

The new "control panel" dropdown menu is different from the existing forum dropdowns; with the forum dropdowns, clicking on the respective button ( e.g. Software Development ) goes directly to the Software Development page, hovering over the button brings up the dropdown. With the control panel button, hovering does nothing, and it's only possible to get to the control panel by clicking the button, then clicking the "user control panel" button in the dropdown menu..

I suggest that the control panel button is made like the forum buttons, i.e. click on it to go directly to the user control panel, and hover on it to bring up the new menu.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Nice idea. What sort of challenges did you have in mind?

MattEvans 473 Veteran Poster Team Colleague Featured Poster

I think Open GL is best for newbies, you can work on open GL easily.

That's a good thing anyway IMHO. 3D graphics is hard enough already without the API trying to kill you along the way.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Hey, sorry for the delay, been a bit busy.

No I am using it for Robot motion planing.

Cool.

DO U HAVE ANY MORE INFO ON THIS? COULD U EXPLAIN ME ME THE OPEN SPARSE GRAPH?
TUTORIAL, SITES, PUBLICATIONS E.T.C

Well, it's open space graph, but the sparseness of the environment is a factor in choosing the method used to generate the graph... There isn't a one-size-fits-all method, because you get a better result using a different method for different environments.

E.g. for an environment that's mostly open space, with a few obstacles that are roughly the same size, you can create the Voronoi tesselation ( http://mathworld.wolfram.com/VoronoiDiagram.html ) of the obstacles ( treating each obstacle as a point ), if you look at the picture on that site, treat the lines as the arcs and the junctions as the nodes of a space graph, following any path through that graph will keep the agent at a maximal distance at all times between obstacles, running standard a-star on that graph will give the shortest path that maintains such a maximal distance ( although this isn't necessarily the shortest path through the space itself, since the constraints conflict somewhat ). However, with obstacles that are different sizes, or very large, you have to do a lot of 'repair work' on the graph before it's useable...

If the environment is mostly obstacles, or narrow paths ( like a maze ), you'd get a better graph by …

William Hemsworth commented: Epic post :) +5
MattEvans 473 Veteran Poster Team Colleague Featured Poster

Moved here ( from Coldfusion )

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Also, it's no harder to work with graphics in C++ than it is to work with graphics in (nearly) any other language. Possibly easier.. since OpenGL is a C library, and OpenGL is, IMHO, the nicest way to work with (3D) graphics.. :)

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Some questions to you:

- are you using the A* for AI character path planning? ( usual case ), is the 3D space unbounded? if so, are you ok with the fact that 3D A* search in infinite space will nearly always find a path, but that the path might well just go over ( or under ) all of the obstacles?
- are the obstacles dynamic ( moving )? if not, it's nearly always better to calculate an open space graph ( i.e. find waypoints between the obstacles, connect waypoints that are visible from each other together ) and then run A* on that graph, than it is to run A* on dense uniform grids.. if the obstacles are moving, you need to incorporate the movement in the A* search, else you'll hit a timestep problem ( e.g. a path that existed at the beginning of the search stops existing after the search has finished ). the timestep problem can be dealt with in simple A*... but.. it will obv. become more difficult to deal with as you add layers to the algorithm..
- A* becomes evil when it can't find a path quickly, i.e. if no path exists, A* will expand every reachable node. you have to either limit the input node-set, or limit the number of iterations of A*. limiting the number of iterations of A* means a search might terminate with fail even when a valid ( but long, winding, complicated ) path …

Ezzaral commented: Good information here. +13
MattEvans 473 Veteran Poster Team Colleague Featured Poster

Why would you expect the return value from Math.random( ), to have the same value when the function is called twice? That's kind of the point of Math.random( )...

Store the result of the first call to Math.random ( ) into a global variable, and use that value in all the places that depend on that value... Variables declared in one top-level block of Javasript have the same value in subsequent blocks on the same page. So, in the second block, instead of:

var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();

just use:

document.write(Quotation[rand1]);
MattEvans 473 Veteran Poster Team Colleague Featured Poster

To center a block-type object, within another block type object, use this code on the object that you want to be centered ( i.e. on the inner object ):

style="margin-left:auto;margin-right:auto;"

although, tbh, text-align:center; really should work, since an image isn't supposed to be a block-type object.

anyway, for best compatibility, use text-align:center; on the outer object, and margin-left:auto;margin-right:auto; on the image.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Oh. I think the output of your program is confusing you... When you print an enum value ( using iostream operator<< ) it prints the integer value of the enum.. so when your program outputs:

Player one has:
31

this is a 3, and a 1 stuck together: not a 31.

so that's the 3 of clubs... output a space inbetween the two numbers =).. eg.

cout<<hand1[s].Value<<" ";
cout<<hand1[s].Type<<endl;

to print an enums "tag", you pretty much have to do:

switch ( value )
{
  case Card::diamond: 
    std::cout << "diamond";
    break;
  case Card::club:
    ...etc..
}
MattEvans 473 Veteran Poster Team Colleague Featured Poster
void deal()
{
  int t=0,p=0;
  const int N=6;
  Card hand1[(N/2)];
  Card hand2[(N/2)];
  for(int i=0;i<N;i++)
  {
    //! since N is a constant, (N%2) will always be constant ( zero ): thus 't' will constantly be incremented, and the stack will get screwed up as writes are attempted outside of the allocated space for 'hand1'. you probably mean (i%2).
    if((N%2)==0)
    {
      hand1[t]=deck[i]; //even values of the deck are distributed to hand 1.
      t++;
    }
    else
    {
      hand2[p]=deck[i]; //odd values of the deck are distributed to hand 2.
      p++;
    }
  }
  showdeck(hand1,hand2,N);
}
void showdeck(Card hand1[], Card hand2[],int N)
{
  int s =0;
  cout<<"Player one has:\n";
  while(s<(N/2))
  {
    cout<<hand1[s].Value;
    cout<<hand1[s].Type<<endl;
    s++;
  }
  //! you don't reset 's' to zero here, so the following loop will never start. 
  cout<<"Player two has:\n";
  while(s<(N/2))
  {
    cout<<hand2[s].Value;
    cout<<hand2[s].Type<<endl;
    s++;
  }
}
MattEvans 473 Veteran Poster Team Colleague Featured Poster

Post the current ( compiling ) version of your code. Also post the error message you receive.

Please use code tags ( http://www.daniweb.com/forums/misc-explaincode.html ) whenever posting code here.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

How are you using the result of the regex match? Perhaps you're using the result incorrectly, because that seems backwards.

Check regexes on the tester application here: http://www.zytrax.com/tech/web/regex.htm#experiment... ( in this app, you don't need to include the surrounding slashes "/ /" around the regex )

( EDIT: you should also use ^ and $ around the regex, unless you know exactly what you're doing, e.g. use /^[0-9]$/ and /^[^0-9]$/.. )

MattEvans 473 Veteran Poster Team Colleague Featured Poster

no, ^ as the FIRST character INSIDE the square brackets means that the whole set is negated, i.e. the set of characters is a set to NOT match.. eg:

[^x] means not x

and ^ as a character other than the first character in the square brackets means that a literal ^ is an option:

[x^] means x or ^

if it's outside the brackets, it means something different, and what it means depends on what else is in the regex before that.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

alpha = [A-Za-z]
numeric = [0-9]
special characters = could be [^A-Za-z0-9], but it depends on your definition of 'special'. usually it's prefered to treat _ ( underscore ) as non-special at minimum, thus: [^A-Za-z0-9_]

when a character group ( enclosed in square brackets ) starts with ^, it means 'not': [^a-z] means "anything but the characters a-z". when ^ is in a character group but not at the start, it means the literal ^ ( caret ) character.. e.g. [^^] means "anything but ^".

when a regex pattern starts with ^; it means "bind to the start of the string*", and it will only be able to match if the regex matches from the very beggining of the string, similarly $ at the end of a regex means it will only be able to match if the regex matches up to the very end of the string, so ^ at the beggining AND $ at the end means only match if the entire regex matches the entire string. ( otherwise, a regex will match if any part of the string matches the rules. )

( * or to any given line, but thats complicated so don't worry about it for now ).


/^[0-9]*$/ means match a complete string that contains 0 or more numbers, this is what * means ( i.e. an empty string, or a string containing only numbers )

/^[0-9]+$/ means match a complete string that contains 1 …

OmniX commented: Great informative reply. Thankyou! +1
MattEvans 473 Veteran Poster Team Colleague Featured Poster

Here's a link to that paper on cockroach movement: http://portal.acm.org/citation.cfm?id=97882.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

There are loads of errors:

- public / private blocks shouldn't be inside methods, only inside classes ( separating variables / methods ).

- function calls look like this a.shuffle() , not like this a.shuffle .

- the showdeck method seems to be dependant on the variables in deal, that's not going to work.

- its int main() , int main( void ) or int main( int argc, char * argv[ ] ) . not void main() .

- this:

deck temp = deck[i]; //swap the values
deck[i] = deck[r];
deck[r] = deck temp;

should probably be:

Card temp = deck[i]; //swap the values
deck[i] = deck[r];
deck[r] =  temp;

or better yet: std::swap( deck[i], deck[r] ); .

- You need to qualify access to the enum values in Card, e.g.: deck[i].Type = diamond; should be deck[i].Type = Card::diamond; .

- You have "\n" in places where it's not supposed to be:

cout<<hand2[s].Type\n;

perhaps you mean:

cout<<hand2[s].Type << "\n";
MattEvans 473 Veteran Poster Team Colleague Featured Poster

Well, I'm not sure how far you've read yet, but this site is good for info on simulating animal / human / vehicle behaviour:
http://www.red3d.com/cwr/steer/ and http://www.red3d.com/cwr/boids/ . The site also has loads of links to other pages.

I wouldn't imagine that the dream aquariam uses inverse kinematics very heavily, although maybe for the crab.. There's been alot of research into realistic movement of cockroaches ( strangely enough ) so if you want to move around a structurally similar creature, that research might prove useful. I will send you a link I have with implementation details of cockroach movement tomorrow ( I don't have it here )

Alternatively, this link describes a method for simulating articulated characters ( particularly ragdolls ) using a particle engine and constraint relaxation. I've actually implemented this to see if it'd be useful, and, whilst I didn't find it useful ( only because it didn't combine too well with an existing rigid-body mechanics simulation ) you might.. http://www.gamasutra.com/resource_guide/20030121/jacobson_01.shtml. You can also use a particle engine ( with certain modifications ) to drive animal / human movement ( although only macroscopically ).

For an underwater aquarium, you'll also want to look at water simulation.. specifically look at fake caustics, wave simulation, and err... a nice informal ad-hoc method - perterbing each vertex's x co-ordinate by sin ( v.y + time ) in a vertex shader.

What language are you using? There are usually some free libraries …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Well. the most important question is, what kind of algorithms do you intend to use? There's many different types of procedural animation. A few from the top of my head:

- mechanics simulation ( rigid body, cloth, continuum )
- inverse kinematics for character movement
- chaotic functions ( mostly used for textures )
- individual character movement driven by AI
- massive groups of character movement driven by social simulation
- particle engines for effects
- other general, informal, ad-hoc stuff

EDIT: - also, path following an explicit / implicit curve is a pretty common/easy to use procedural method.

And most of these require different areas of research.

I wouldn't say that procedural is 'the future' in all circumstances. Taking full control of a procedural scene can be hard - keyframes allow for fine grained control. If you're making movies - it's easy to run simulation and then fix up discrepancies and make changes using manual keyframing. In interactive real-time it's not so easy, you have to make sure the algorithm being used looks right in many different situations.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

bones often have keyframes... except they're usually rotation keyframes in a bone's local space. if you mean skinning.. the general idea is:

> import vertex data such that each vertex has an associated list of influences ( integer ids ) and weights ( normalized across the influences ).

> import structure data such that each influence has a bind space matrix ( transform of the influence when the skin was bound to the bone )

> assuming you only have one influence per-vertex, for every redraw, loop through all vertices, and transform each vertex by the inverse of the bind space matrix multiplied by the transform of the influence at THIS moment in time. if using more than one influence per vertex, transform a copy of the original vertex by each influence and take a vertex weighted sum ( using the weights associated between each vertex and influence ).

otherwise.. your question is quite general.. perhaps elaborate on what exactly you mean by 'procedural', i.e. how do you intend to drive the movement? something physics based? if you want to do rigid body physics, read tutorials on 3-d rigid body physics without transform hierachy ( i.e. just objects without bones ) and on 2-d rigid body physics with hierachy ( usually expressed as constraints )... and then try and combine the two.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Actually, the first equation I gave wasn't so far wrong. In case your not sure what I'm suggesting, I've attached an image showing the 'reason' why the first equation is wrong, and the second is 'more right'.

The vector from the moving point to either of the line's defining points can be used to determine whether or not the line and point intersect, since when acos(A DOT B) = 0 ( i.e. when the angle is zero ) the argument must be 1. Thus, you can skip the evaluation of the acos, and/or write a formula to determine whether or not the argument approaches 1.

You can also avoid the normalization of the two vectors. In the attached image, it can be seen that working out whether or not the angle between the point and the line is zero is more difficult than working out if the angle between the parallel line that passes through the first line endpoint is zero, since when the dot product is zero, the vectors are perpendicular irrespective of their lengths. Thus, rather than try and incorporate the length between A and C ( which changes with respect to time ) in an equation, you can simply check if the dot product between that perpendicular and the vector between the point and the line startpoint reaches zero.

For finding a perpendicular vector to a given vector in 2d:

perp ( x, y ) = [ -y, x ]
..or..
perp ( x, …
MattEvans 473 Veteran Poster Team Colleague Featured Poster

heh, dumb mistake, the line and point collide when:

( NORMALIZE (P-L0) DOT NORMALIZE(L1-L0) ) = +1
..or..
( NORMALIZE (P-L0) DOT NORMALIZE(L1-L0) ) = -1

for a segment, leave out the -1 case, you still need inclusion checking afterwards, and I think you'd need at least two roots, since the line might touch the point as it rotates on the other side of it's "circle", and that might fall outside the segment.

that makes the expansion alot more ugly. expanding with acos / atan ( similar to how you're going about it ) would also require the normalization, and is unecessary when only checking for the angle 0..

if you use a general root finder, the complexity of the expression isn't a problem ( although the time taken to solve might be )

MattEvans 473 Veteran Poster Team Colleague Featured Poster

I don't have a complete answer to this, ( not a mathematical genius! ), but you said you wanted to hear how people might go about this.. and the following is how I'd start:

assume:

ax, ay = rotation origin for the point
ar = initial rotation of the point
ad = distance of the point to its rotation origin
av = angular velocity of the point

for the line segment, I'd temporarily treat it as an infinite line passing through its own rotation origin and through another point, which I'll define as b ( with same attributes as the point a ). If the systems are as in the image you depicted, it seems like it should be sufficient to work out whether or not the point intersects the infinite line; if the intersection is within the line segment, then it's a collision, otherwise, the objects will never collide...

.. incidently, in this setup, the two objects will either never collide, or will collide an infinite number of times. I guess that you want the smallest positive time at which the objects will collide, this can then be multiplied by the angular velocity to work out where the objects are.

now... collision between an infinite line through the points L0 and L1 and another point P occurs when:

(P-L0).(L1-L0) = 0
[ where . is the vector dot product ]

the actual position of the point P at any time ( t ) is given by:

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Yes. The "m" flag is more useful combined with either global match or global replace, since then you can perform one operation per line. For the test you're doing, it's gonna return true if any of the lines in the input match.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

see: http://www.perl.com/doc/manual/html/pod/perlre.html

specifically the modifier:

m - Treat string as multiple lines. That is, change ``^'' and ``$'' from matching at only the very start or end of the string to the start or end of any line anywhere within the string

thats a perl site.. but php ripped perls regex syntax pretty much exactly.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

There's no "simple tag". Quite a few things can go wrong when you look at a page developed using one browser in another browser ( it shouldn't be the case, but it is ). The best method for ensuring you don't get this problem is to look at the site in multiple browsers while developing it, and address/learn from each problem as it arises.

On Linux, you can install Wine and IES4Linux ( http://www.tatanka.com.br/ies4linux/page/Main_Page ) to get an old ( version 6.0 ) of Internet Explorer running. You should really test in other popular browsers ( Firefox, Opera, Safari ) aswell.

You can also make sure that the page is written using "standards-compliant" (X)HTML/CSS/etc... although, this will help you less than actually seeing the site in each browser and working out what things/combinations of things work acceptably everywhere.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

To me, Javascript/HTML/CSS animation always feels like an ugly hack: sure there are libraries available to assist with the lack of any built-in support for graphics*; but then there are libraries to render 3d scenes in graphing calculators [ just because you 'can' doesn't always mean you 'should' ]. Flash & Silverlight provide built-in support for graphics, the dedicated plugin runtime environments are better tailored & optimized for that kind of thing.

* ( support for static images doesn't count as "graphics support" )

Of course, there's usually better availability of JS than there is for Flash or Silverlight [ I don't install the plugins for either, personally ]. For simple animations, or animations that should be seamlessly integrated into a webpage, use an animated image format and/or JS. It depends how complicated you want animation to be really - simple fixed animation can usually be done as an image / videoclip anyway.. complex interactive animation is not really suited to JS ( in that it's not the best option available ).

As to why there aren't any available JS animation design studios.. No idea. Someone will probably consider it: crazier things have been developed.

For Q2: Javascript isn't displayed: it's just used to move things around/change properties of HTML+CSS objects. Of course, there may be discrepancies in timing under different environments.. or outright difference in the way a feature is implemented in JS; but it's ( very ) much more likely that the difference is …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

DirectX doesn't necessarily have better performance : it really depends how the graphics card manufacturers build their cards, and write their drivers. Without hardware acceleration, DirectX is probably faster, but only on Windows ( and only because the software implementation of OpenGL from Microsoft isn't great ). With hardware acceleration, the limiting factor is the card itself, not the API.

However, DirectX only works on Windows/XBox anyway - OpenGL works on a larger number of platforms.

Read: http://www.gamedev.net/reference/articles/article1775.asp, it's pretty unbiased and ( importantly ) it's up-to-date. Much discussion you'll find on the net about OGL vs. DX is way out of date.

Nick Evan commented: Thanks for the correction/follow up +9
MattEvans 473 Veteran Poster Team Colleague Featured Poster

And as far as the complexity analysis is concerned, one should rather use tried and tested library / proven methods than worrying oneself with premature optimization.

I absolutely agree, unless the task at hand is simple enough to be considered a "primitive operation" in itself, and personally, I consider looping over a string's characters to be something thats -- in all practical purposes -- irreducible, without either losing generality [ i.e. replace wont work with ranges ], or requiring a complex framework [ regex support ranges just fine, but you can't deny they could be considered overkill in many contexts ]. Regex are fast, but they have to be pre-processed ( initial overhead ), and the abstraction of regexes incurs a cost ( unless the implementation is really, really excellent )

I wasnt strictly refering to sanitising as in sanitising a post/request value, I was considering sanitising a string for a database or a shell script, where input corruption is much more acceptable than integrity corruption.. but I pretty much forgot this is the Javascript forum, and any sanitization of that type should ( must! ) be done at the server anyway... and thats not gonna be done in Javascript.. unless using old-school ASP+serverside JS.. >_>

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Regardless of whether you're doing this for input sanitising or not, the method I suggested has the best complexity guarantee.. it's always O( n ). Worst case, assuming a string of all special characters, for calling replace multiple times is O( 1 + 2 + 3 + 4 + .. + n ), and I have no idea about the worst case for regexes; but I assume it's not as good as O( n ).. [ Even it it is O( n ), the implicit factor on n and the initial overhead is likely higher than it is for manually doing it by looping, although, if the input strings are epicly massive, maybe the overhead of regex setup is outweighed ]. Of course, if you blacklist the special characters, you have to multiply all those n's by a factor k ( number of illegal characters ), if you whitelist only alphanumeric characters, you can check for the character being in the range a-z,A-Z,0-9 using charCodeAt(i) and the known ascii values for the starts and end of those ranges == a small constant factor.

Looping and checking each char is also the simplest one to write/understand, so it's a win all round IMHO.

That doesn't seem to be the case here since converting special / blacklisted characters to their equivalent codes doesn't serve any purpose.

I disagree, this could certainly be used as an effective one-way sanitization technique -- coupled with wrapping the processed input in a pair of …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

There's at least two ways, one is to put all the code that is supposed to be executed after the response has been obtained into the end of the onreadystatechange handler function; the second way ( essentially the same ) is to split the requesting function into two functions, one that does the stuff that should occur before the readystate changes then issues the request then returns immediately, and one that does the stuff that occurs after the response is recieved, and call the second function from the readystatechange handler function.

The claimed issues with regard to bad support for syncronous requests are with relation to the onreadystatechange function not being called in versions of firefox ( i've never personally verified this ); if you're using a synchronous request though, you shouldn't need to worry about this issue anyway : the call to request.send won't return until the readystate has changed to the response recieved state, so you should be able to just write:

req.open("POST", "/includes/_process/getPortfolioCount.php", false);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send(null);
if ( req.status == 200) {
  document.getElementById('portfolioCount').value=req.responseText;
  alert(req.responseText);
  //...etc...
} else {
  //error occured
}

( notice that a readystate change handler never need be assigned )

The only issue with synchronous otherwise, is that the javascript application will hang ( not continue to execute anything ) until a response is recieved.