|
Post by scalion on Oct 19, 2023 11:25:02 GMT 1
Hi all,
While looking to develop a collision algorithm I came across a post concerning a fluid simulation. From there I sought to develop a simulator and therefore needed to create a distance function. But how can I visualize the result of my function quickly? This is where I developed this very practical little utility which uses the EVAL function of GFA-Basic which is very very useful! So I'm sharing in the hope that it will be as useful to you as it is to me.
|
|
|
Post by (X) on Oct 19, 2023 17:21:39 GMT 1
Definitivement un atout!
|
|
|
Post by scalion on Oct 20, 2023 12:03:58 GMT 1
This version is more finalized in terms of display. We can now move the grid in x AND in y. We also have the min and max points closest to the mouse which are displayed.
|
|
|
Post by (X) on Oct 20, 2023 14:58:27 GMT 1
Ok, je suis accro. Lorsque j'abaisse la valeur Accurate, je vois comme prévu moins de points sur le graphique et le curseur (point rouge) se déplace par bonds discrets. J'ai scanné le code et j'ai essayé de comprendre exactement à quoi se réfère Accurate... Avez-vous une explication ou une définition simple ?
Ok. I'm hooked. When I lower the Accurate value, I see as expected fewer points on the graph and the cursor (red dot) move in discrete jumps. I scanned the code and tried to understand exactly what Accurate refers to... Do you have a simple explanation / definition?
|
|
|
Post by scalion on Oct 20, 2023 20:50:27 GMT 1
Il faut d'abord que j'explique comment la courbe est dessinées à l'écran. La largeur de l'écran correspond à une unité. Cette unité va de la limite LimitX1 à LimitX2. DEBUT DU DESSIN : Au début du programme elle sont définie de -5 à +5 (dans la dernière version). La valeur Range est donc initiatisée à 10 (+5--5=10). Au tout début du dessin la valeur AccurateLevel est mise à zéro. Cette valeur indique que seulement 3 points (AccurateN=3) vont être dessinés (en terme d'unité) à 0, 0.5 et 1. Avec les limites à -5 +5 cela donne -5,0 et 5. AccurateX est la valeur de x de la fonction f(x) et elle est initialisée à LimitX1 (-5) L'espacement entre les points est stocké dans AccuratePx = Range (10) / 2 = 5. A chaque points dessiné la valeur AccurateIndex est incrémentée. On ajoute AccuratePx (5) à AccurateX. Quand AccurateIndex atteint AccurateN on incrémente AccurateLevel et on remet AccurateIndex à zéro. Si AccurateLevel atteint AccurateLimit alors le dessin s'arrête. Sinon on passe à AccurateLevel = 1. Dans ce case particulier AccurateN est initialisé à 2. L'espacement entre les valeur de x reste le même et on commence simplement à 0.25 (en terme d'unité) soit LimitX1 + Range * 0.25 (ou Range / 4 dans le code). PROGRESSION DANS LA PRECISION : Pour les valeur de AccurateLevel suivante (2,3,4,etc...) On divise à chaque fois l'espacement AccuratePx par 2 et on initialise x à LimitX1 + AccuratePx/2 (ou bien LimitX1 + Range / (2^(2+AccurateLevel)))
POURQUOI :
Cela permet de n'afficher qu'une seule fois chaque point de la courbe en parcourant sa largeur de manière progressive en augmentant le niveau de précision à chaque passage..
Je vais poster un petit programme explicatif...
|
|
|
Post by (X) on Oct 20, 2023 21:05:24 GMT 1
OK. Si j'comprends bien, Accurate reflète le nombre de points calculés.
|
|
|
Post by scalion on Oct 20, 2023 21:28:33 GMT 1
OK. Si j'comprends bien, Accurate reflète le nombre de points calculés. Oui c'est ça, Avec AccurateLimit = 0 on a 3 points, 1 on a 5 points, 2 on a 9 points, etc... La formule est 1+ 2^(1+AccurateLimit).
Voici le petit programme :
|
|
|
Post by (X) on Oct 20, 2023 21:59:24 GMT 1
A+
|
|
|
Post by Roger Cabo on Oct 21, 2023 17:54:49 GMT 1
|
|
|
Post by (X) on Oct 21, 2023 18:33:39 GMT 1
That is an excellent goal Roger! Seeing scalion's latest demo prompted me to ask him about collaborating on a graphing library: "Lib_Graph.lg32". I forgot I already started this in May 2022... see: gb32.proboards.com/thread/487/lib-graphI got to V5, but, I ran out of steam. Why did I stop? I guess when my perceived "return on investment" goes below a threshold or if the project gets too complicated, I loose interest and leave it for a time when I'll have fresh eyes and a better understanding.
I should definitely revise and publish V5.
|
|
|
Post by (X) on Oct 21, 2023 18:42:26 GMT 1
(X)... it's time to: "Pull your finger out!"
|
|
|
Post by scalion on Oct 21, 2023 19:15:45 GMT 1
|
|
|
Post by (X) on Dec 24, 2023 15:40:33 GMT 1
This version is more finalized in terms of display. We can now move the grid in x AND in y. We also have the min and max points closest to the mouse which are displayed.
|
|
|
Post by Roger Cabo on Dec 25, 2023 12:50:53 GMT 1
This one has an error. min(4,max(-4,cos(t ?1.57)/sin(-t ?x/2-1.57)^3)) seems its: min(4,max(-4,cos(t+1.57)/sin(-t+x/2-1.57)^3)) from what i see in the link.. This graphtoy is great. I' just wondering how they un-puzzel the given terms! And how Gb32 un-puzzle code the syntax as well.
|
|
|
Post by (X) on Dec 25, 2023 17:13:26 GMT 1
This was a tricky one!
Your suggested correction for GraphToy seems to output: This link seems to work: "https://graphtoy.com/?f1(x,t)=min(4,max(-4,cos(t+1.57)/sin(-t+x/2-1.57)%5E3))&v1=true&f2(x,t)=&v2=true&f3(x,t)=&v3=false&f4(x,t)=&v4=false&f5(x,t)=&v5=false&f6(x,t)=&v6=false&grid=1&coords=0,0,28.295372292000028" I think maybe proboards does not store the link properly? Gonna have to check again. It seems the link's '+' signs gets permutated to '%20' (space characters) by ProBoards 'link' function or when the string ends up in the browser's URL field: "https://graphtoy.com/?f1(x,t)=min(4,max(-4,cos(t%201.57)/sin(-t%20x/2-1.57)%5E3))&v1=true&f2(x,t)=&v2=true&f3(x,t)=&v3=false&f4(x,t)=&v4=false&f5(x,t)=&v5=false&f6(x,t)=&v6=false&grid=1&coords=0,0,28.295372292000028"
As suggested by BING. If you replace the '+' with %2B this should work. And it does. Try the new link below.
|
|