Animate the PI = 4 experiment

Page 5 of 9 Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next

Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Mon Nov 04, 2019 7:37 pm

.
Animate the PI = 4 experiment - Page 5 Button10
Both spheres traveling along their tracks in a downward direction have just past their initial sections and red starting lines. The track angle rotation of the curved track sphere is already apparent. Oh, and buttons. And off of daylight savings.

Using a check-box to control pausing is bad
Like teats on a boar bad? The new Pause and Next Frame buttons work slightly better than they did as check boxes. If in haste, one presses Next Frame instead of Pause, the screen will still pause. Here’re the two new items on the end of the parameters list.
Code:

 parameters =
 {
 timeInSecs: 40,
 CycloidRoll: true,
 twopivt: false,
 twopir: true,
 color: "#FFFF00",
 StepAhead: false,
 pauseButton: function(){ pauseButtonPressed() },  
 nFrameButton: function(){ nextFramePressed() }  
 };

The gui additions.
Code:

      gui.add( parameters, 'pauseButton' ).name("Pause");
      gui.add( parameters, 'nFrameButton' ).name("Next Frame");

The two event functions.
Code:

 function pauseButtonPressed()
 {
 // toggle the current state
 paused = !paused;
 };
 
 function nextFramePressed()
 {
 if ( paused ) {
 stepA = true;
 }
 else if ( !paused ) {
 paused = true;
 stepA = false;
 }
 };

I haven’t begun thinking/worrying about using the spacebar.

The PI switch is working. Here’s the current animate function’s circular track section code again, with two new if/else statements.
Code:

 else if (( distNextC >= cTracSectK ) && ( distNextC < cTrackLengthK )) {
 // Curve motion. distance traveled/CTrack circumference.
 // 2PI*v*t/2*PI*r = PI*v*t/PI*r).  
 if ( piTopKOrNot ) {  
 numerator = piK * (distNextC - cTracSectK);
 }
 else {
 numerator = piG * (distNextC - cTracSectK);
 };
 if ( piBottomKOrNot ) {
 denominator = piK * r;
 }
 else {
 denominator = piG * r;
 };
 var trackAngle = numerator/denominator;
 sphereC.position.set( r*Math.sin( trackAngle ), 0, r*Math.cos( trackAngle ));
 sphereC.rotation.y = trackAngle;
 distTraveledC = distNextC;
 curSectionC = nexSectionC;
 }

Nevyn wrote.
A = 2PIg*v*t/(2*PIk*r)
= PIg*v*t/(PIk*r)

Once you have this up and running, we might try using that full equation and see how it goes. If we find that we need it, then that is good confirmation of Miles angular velocity equation.
Airman. A is the angle traveled by the object in circular motion. You said that if the pi’s used in the numerator and the denominator were the same, the angle traveled would reduce to, A = vt/r.

As you guessed on 10 October, and as I had previously coded correctly through trial and error - but which can now be verified true, motion around the circular track operates correctly only when the distance traveled is based on geometric pi, while the circumference must be calculated using kinematic pi. The simplification A = vt/r is not valid.

Would you care to elaborate on why this is a good confirmation of Miles angular velocity equation? I understand that curved motion is, in fact, a function of the radius of motion. How does that affect ( effect/affect I don't know how this word works either) the PI equal Four application?

P.S. remembered to add the gui additions.
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by Nevyn on Mon Nov 04, 2019 11:23 pm

It currently is not confirmation of Miles' angular velocity equation, because it is not being used. You need to replace the v variable in my equation you posted above with the angular velocity equation. My guess is that it won't make much difference, if any. At the sizes we are working at here, the curvature of that equation is so close to straight that the differences will be small. However, the smaller you make this track, the more it will become important and needed.

It would probably be more correct to add it in rather than leave it out, but it isn't that important for this problem and what you are trying to show. I guess I would be interested to see it applied, and maybe run 2 tracks next to each other: one with and one without that equation. Your code is not setup for that, though, and it would take some thought to make it so. Actually, as I think about it, it wouldn't be that hard, but probably not worth the effort regardless.

I knew that A=vt/r was not right. It doesn't even look right. I was also pretty sure that the top half of the equation I was building would use 3.14, and the bottom half would use 4, once I realised that I had re-derived the same equation that I did in my Spin Velocity paper. It is always good to have confirmation, though.

I noticed you expanded this function out a bit:
Code:

 function nextFramePressed()
 {
   if ( paused ) {
     stepA = true;
   }
   else if ( !paused ) {
     paused = true;
     stepA = false;
   }

But you didn't need to. They are actually equivalent, but yours uses more effort to perform the same work. Firstly, you don't need that if( !paused ) of the else statement, because if the first condition fails (if( paused )) then you know that paused is equal to false, so you don't need to test it again. Secondly, you don't need the if statements at all, because we don't care about the current state of anything. We just want to set paused to false, so that the next frame is executed, and stepA to true, so that it will pause after it executes it. This way, the next frame button works in all situations. Even if the system is not currently paused, it will pause it after executing the next frame.
Nevyn
Nevyn
Admin

Posts : 1796
Join date : 2014-09-11
Location : Australia

http://www.nevyns-lab.com

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by Nevyn on Tue Nov 05, 2019 7:18 pm

I think I see a slight misunderstanding of how boolean logic works. When a boolean expression is being evaluated, not all of that expression may actually be evaluated. Let's look at some examples to see how this operates.

AND

In an AND expression, generally denoted by && in the languages we have been dealing with, you have at least 2 terms in the expres​sion(we will keep it simple and only have 2). The AND operator requires that both sides evaluate to true, or the whole expression fails. Therefore, since we need both to succeed for the whole expression to succeed, if the first part fails, then we don't need to execute the second part. We already know that the whole expression is going to fail, so why waste the time evaluating the second expression?

OR

In an OR expression, generally denoted by ||, we find the opposite of an AND expression. In this case, either expression can make the whole expression succeed. So if the first part evaluates to true, then there is no need to evaluate the second part. Only if the first part fails will the second part be evaluated. So if the second part is evaluated, we know that the first one failed. There is no need to check it again.

The same things apply to if and else statements. If an else expression is being evaluated, then we know that the preceding ifs and else's have already failed. There is no need to check them again.

For these reasons, you must never rely on the execution of code in a boolean expression. That is, you should not call some function that performs something that you need done, because you don't know if it will get executed. That sort of code belongs inside of the if or other control structure, never in the boolean expression. Note that you have not done this, I am just pointing it out.
Nevyn
Nevyn
Admin

Posts : 1796
Join date : 2014-09-11
Location : Australia

http://www.nevyns-lab.com

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Tue Nov 05, 2019 7:22 pm

.
Animate the PI = 4 experiment - Page 5 Header10
The latest includes html information: Miles Mathis’ Physics page link, Title, list of controls and minimum Spacebar directions.

Here’s the extended Spacebar directions; holding the spacebar down allows action to continue; releasing the Spacebar pauses motion. Briefly pressing or tapping the spacebar advances the scene by frames. Perfect, although a Spacebar escape might be nice.

Sir, I tried following your directions as carefully as I could, thank you very much. I deleted the else condition but I couldn’t make the Next Frame button work without the if statement. As it turns out, the Next Frame button is also working perfectly. Using Next Frame will create a Pause, and each next Frame button click advances the scene a frame forward. Here's the current next step event handler.

In trying to post this message I see you are getting more into the logic. Good.
Code:

 function nextFramePressed()
 {
 if ( paused ) {
 stepA = true;
 }
 else {
 paused = true;
 stepA = false;
 }
 };

I found a threejs example that contains html info and uses the keyboard, “three.js - platformer demo”, and wittled the nine keys and two functions down to one. The same Next Frame logic now appears in the new keyboardControl function.
Code:

 var keyboardControls = (function() {
 var keys = { SP : 32 };  
 var keysPressed = {};
 (function( watchedKeyCodes ) {
 var handler = function( down ) {
 return function( e ) {
 var index = watchedKeyCodes.indexOf( e.keyCode );
 if( index >= 0 ) {
 keysPressed[watchedKeyCodes[index]] = down; e.preventDefault();
 if ( paused ) {
 stepA = true;
 }
 else {
 paused = true;
 stepA = false;
 }
 }
 };
 };
 window.addEventListener( "keydown", handler( true ), false );
 window.addEventListener( "keyup", handler( false ), false );
 })([
 keys.SP   ]);
 })();

This PI Equal Four application runs horribly slow on my internet Explorer. I saw a tutorial and read somewhere that requestAnimationFrame functions varied across different browsers. They recommended adding the following code at the top of the script. I did and saw no change, does it have any value or should I get rid of it?
Code:

 window.requestAnimationFrame =
 window.requestAnimationFrame ||
 window.webkitReqeustAnimationFrame ||
 window.mozReqeustAnimationFrame ||
 window.oReqeustAnimationFrame ||
 window.msReqeustAnimationFrame ||
 function(callback) {
 window.setTimeout(callback,1e3/60);
 };

Seems like I’ve been making lots of changes lately, I haven’t included the CSS style or div info code changes, I’ll wait a bit.

However, the smaller you make this track, the more it will become important and needed.

The tracks don’t need to change size, they are a maximum distance reference limit, 10*r, with r being a millimeter or a light year. Allowing spheres to be much smaller than the tube – in radius, as small as we like, they will travel along the tube centerlines. It would then be possible for this app to show Miles’ or your full angular formula.
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Wed Nov 06, 2019 7:40 pm

.
Nevyn wrote. I think I see a slight misunderstanding of how boolean logic works. When a boolean expression is being evaluated, not all of that expression may actually be evaluated.
You’re right, using the if statement I assumed I needed to cover all cases. Saving energy at if statements and explaining why makes for very interesting lessons. You demonstrate a fine ability at logic, you explaining why I do something wrong is scary, and greatly increases your credibility. I've missed some of what you've said, overall you've certainly taught me a lot, and forced me to learn it too by golly.

Airman said. They will travel along the tube centerlines.

Ok, that’s not correct. The PI=4 Experiment application shows a circular tube track at a fixed radius of curvature, regardless of the sphere size. The tubular tracks mimic StevenO’s PI=4 Experiment. You required it and I must admit I very much like the app’s tubes. Let the animated experiment tracks represent some maximum size, what good is it if we allow smaller spheres without greater curvatures of motion? One may vary timing slightly to accommodate the full formula but then nothing is being compared.

Animate the PI = 4 experiment - Page 5 Sevent10
Seven parallel/concentric sets of PI=4 tracks.

How might we simulate the full circular motion formula? I submit the above diagram as one possibility.

Seven green parallel straight tracks each 10*r long, each tangent to a different concentric blue circle at varying radius of r. Seven initial overlapped 2*r straight sections. The two tracks would be separated according to the spheres’ diameter. The red lines are the 2*r distance markers.

At which point I think, why include straight tracks? We know pi=4. We might want to compare the circular motions of any two different radial tracks. One thought led to another and soon I was looking down at the solar system.

I’m back. I think the existing app’s initial setup might be tweeked or not. I’m happy with it, and feeling pangs of post partum blues. I’m glad you agreed to this project. I’ve learned a lot – concentrating on circular motion. Glad you required the tubes. You never indicated your aproval of the hoops. Come to think of it, I suppose I should try and see whether wireframe tube material is an alternative to the parallel hoops.

Looking slightly ahead, how does this process end? Do I simply post the existing code? Can a standalone app be compiled – able to run without the complete .js sources such that anyone might be able to see it? Did you have any interest in making a running copy available at the Lab?
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Thu Nov 07, 2019 1:32 pm

.
Animate the PI = 4 experiment - Page 5 Manytr10
That last set of seven parallel/concentric track distances was a bit off.

The distances in this diagram have been corrected in order to allow a closeup.  
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by Nevyn on Fri Nov 08, 2019 5:44 pm

You've lost me with these latest multi-track images. I don't see what they offer or what they are trying to achieve. I think you may have misunderstood what I meant by the track being smaller and requiring Miles' angular velocity equation. I meant a complete scale down to the photon level. This would not change the track dimensions in a relative manner, but would just change the absolute distances to be around 10^-24m.

Where does this process end? With something that is publishable, if that is what you want to achieve, or it stops whenever you want, if you just wanted to learn about circular motion and/or programming techniques. I wanted you to take more control of the application and development process, and you have done that. I wanted you to own it. I wanted you to see that you can tackle an idea and progress through it using 3D models to help you see it a bit deeper than just thought alone might have done. I wanted to rip away the training wheels so that you might gain the confidence to approach these sorts of things on your own. I am still here for help and guidance, but you can do things on your own, too.

So, I see this going in one of two ways: you develop a web page that both contains this animation, and a description of what it is showing; or you look through Miles' PI=4 papers and find somewhere that this animation will fit into it so that it can be added to my Interactive Papers section. The latter might be easier, and you may find multiple spots for it, so don't limit yourself to just one. If you want to go that way, then we will need to go through how I put those pages together, but it isn't much different to what you are doing already, so don't be worried about that.
Nevyn
Nevyn
Admin

Posts : 1796
Join date : 2014-09-11
Location : Australia

http://www.nevyns-lab.com

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Fri Nov 08, 2019 7:13 pm

.
Those latest two multi-track images were just concept ideas. Having given it a fair amount of thought I believe concentric orbitals can provide a good way to demonstrate the full circular motion formula. I’ll be happy to work the idea up formally in due course. In no way do I wish to alter the current app as indicated by those two diagrams.

Ripping off my training wheels indeed! I thought it was a race against time to produce a semi-complete package before it was too late. The thought of carrying-on is a great relief. Glad to be at your disposal. Adding to your interactive papers would be wonderful.

Animate the PI = 4 experiment - Page 5 Tubesa10
In this image, the 122 hoops (alas, no flames yet) – 61 per track, have been replaced by two cylinders and a torus.

Cylinders and Torus. Rather than some transparent solid, I went with wireframe material. The code is far more efficient, saving 73 code lines, (down from 526 to 453), including 122 distance hoops built into the geometries. The downside is – the spheres are much less visible. The cross sections of the tubes or torus should appear round; four sides is an unacceptable diamond square that draws way too much attention to itself. Eight sides is round enough, and is shown in the image above, but with 8 long 10*r lines come two new alternate spin sets of 8 long spiral lines; 24 grey lines compared to the previous four long green lines. The spheres are much less visible. The only other problem is the “Cannot use import statement outside a module” errors when accessing both new threejs geometry sources.

Tossing out the cylinders and torus and their sources, and sticking with the previous grey circles and long green lines, I nonetheless corrected a gross inefficiency I knew I would eventually get around to. Circles were being re-created 3 times in both the straight sections and curved. Now, yZPCircle is created once. Saving appox 21 code lines, ending at 505. I think I’ll do the same with the 11 track markers. Good to know I’m finally saving energy.
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by Nevyn on Fri Nov 08, 2019 9:35 pm

Can you use a transparent tube and show some screenshots? Wireframe can be useful, but rarely what you want in a final product.

Don't be afraid to use a heavy transparency. Maybe 0.2 for the opacity. You might have to play with the color so that the tube is still visible. Tube transparency could also be added as a menu control, if you want. However, if used for an interactive paper, the menu will be unavailable, so don't get too attached to it.

The markers should be more visible than the rest of the tube, too. They could use some labels for the main ones we care about, showing how they match on both tracks.

What I would really like is for the current section of tube that the balls are in to light up somehow. Maybe they become a different color, a bit brighter than normal, or even a completely different color, whatever works well. The labels could also light up, even if the tubes don't.
Nevyn
Nevyn
Admin

Posts : 1796
Join date : 2014-09-11
Location : Australia

http://www.nevyns-lab.com

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Sat Nov 09, 2019 7:32 pm

.

Can you use a transparent tube and show some screenshots? Wireframe can be useful, but rarely what you want in a final product.
Amn. Of course; here are two sets - white and blue clear materials for comparison.
Animate the PI = 4 experiment - Page 5 Mostly11
Yes I was skeptical, it’s easy to see the mostly transparent, aerogel-like material making up the cylinders and torus do make the tracks appear more unified or defined; the lines aren’t just hanging in empty space. Even though your suggested opacity level looked best there’s no way around the fact objects inside the tube are dimmer. All the lines and hoops were inside the tubes, note the two-toned blue sphere at the right, so I expanded the hoops and marker lines outward.

Animate the PI = 4 experiment - Page 5 Mostly10
There’s one exceptional odd area, the section of torus that intersects with the initial straight section leading to the starting/finishing lines.

The markers should be more visible than the rest of the tube, too. They could use some labels for the main ones we care about, showing how they match on both tracks.
Amn. I eliminated grey hoops that were drawn at the same locations as the red markers and so now the markers are more distinct, let me know if you’d like to make them moreso. Points if you notice the marker horizontal arms are still a bit short.

What I would really like is for the current section of tube that the balls are in to light up somehow.
Amn. Two possibilities come to my over-optimistic, in-experienced mind. 1) install point lights inside each sphere, The tubes, made out of meshBasicMaterial ‘don’t react to light’. They may need to be upgraded to Lambert in order to make the track light up where the sphere is. Or 2) use shader material. That sounds sexier but probably way more complicated.    
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by Nevyn on Sun Nov 10, 2019 5:38 pm

You definitely don't want to use lights, nor shaders either. All you need is to create individual track segments with their own Material object (not shared) and update the color property of the Material depending on whether the ball is in that segment or not.

I don't think the grey markers are needed. They just clutter up the track. The red ones are fine. Maybe make the PI marker a different color to differentiate it.

That small section is caused by the additive blending on two transparent things that are inline with respect to the camera. You can change the blending method, but I don't know what is available and whether it will fix it as you want it to. Worth a go, though.

While transparent tubes will lower the intensity of the ball color, only you really know that. The general user will just see it in that subdued way. It is easy to get used to vibrant colors, but that doesn't mean they are better. I get hooked on vibrancy quite often, and have to convince myself away from it.
Nevyn
Nevyn
Admin

Posts : 1796
Join date : 2014-09-11
Location : Australia

http://www.nevyns-lab.com

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Sun Nov 10, 2019 7:31 pm

.
Animate the PI = 4 experiment - Page 5 Almost10
Thanks for calling me off the lights, I had gotten two stuck in the tube openings.

Just when the hoops and markers were cooperating – the hoops are gone. I take it you want me to drop the four long green lines as well? Done. The red horizontal and vertical lines too?

I'll change the pi marker next. Do you still want labels? Lighting sections of the tubes eh, interesting. I must contemplate that.

Noticed today that there’s no DAT gui when I run this thing in fireFox. No problem, I'll continue using chrome.
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by Nevyn on Sun Nov 10, 2019 9:27 pm

Looking better already!

The red markers could be replaced by something a bit more 3D. They can go outside of the tube, and they can be wider than a line. They also don't need to be transparent, if that works. Think of some sort of join across 2 separate tubes that rises above the tube, with beveled edges that connect to the tubes. That would be 3 pieces: 2 beveled edges and a center piece. The center piece could be what highlights as the ball passes that marker. That's just one idea that could work.

Some textures would probably be useful, too. At least for the balls, but even the tubes, maybe. That does get complicated but you can use the textures from my site to avoid cross origin problems.

What are those red and green thingy's on the bottom right? Failed spheres?

I'm kinda liking the idea of a light being inside the ball. But it would not roll with the ball, but must curve around the circle. Could be tricky, but could look good too.
Nevyn
Nevyn
Admin

Posts : 1796
Join date : 2014-09-11
Location : Australia

http://www.nevyns-lab.com

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Mon Nov 11, 2019 8:04 pm

.
Animate the PI = 4 experiment - Page 5 Rubber10
The two images are intended to convey the resulting ‘dramatic’ light and shodows cast, especially on the curved track.

It wasn’t too difficult to install a point light in each sphere and advance them along with the spheres. They don’t need to rotate. The red line markers are currently transparent rubber grommets that don’t always light up.

The red and green thingy's were point light helpers. Now the helpers are much smaller blue spheres and white octagons identifying the point light source.

I have no problem with the torus/initial straight section overlap.

Now that the grey lines are gone, I turned them into 50 or 60 tube sections. The result, all the internal walls, worked just as well as the grommets and were just as distracting as the grey lines. Now I’m happy without them. Keep it pure and simple, there’s plenty involved in getting the lighting right. That is, of course, if you agree.

Animate the PI = 4 experiment - Page 5 Pntlgt10
Here, the section markers are two concentric circles.

How do I ensure that all surfaces - front, back, and inside of the grommets and tubes are reflecting light?
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by Nevyn on Mon Nov 11, 2019 8:32 pm

Airman wrote:How do I ensure that all surfaces - front, back, and inside of the grommets and tubes are reflecting light?

Every Material object has a side property which can be THREE.FrontSide, THREE.BackSide, or THREE.DoubleSide. This determines which side will be rendered. If the camera is facing the back side, but only the front should be rendered, then it won't render. Set the grommets (and probably the tubes) to DoubleSide and it should work as you want it to.

Try using a SpotLight. This has a position and a direction, which should point along the velocity vector for the ball. This may require some special handling for the curved section (which I was referring to in the last post). You may be able to just set the lights direction to the velocity and everything will work out. Just have a play with it and see what you can do.
Nevyn
Nevyn
Admin

Posts : 1796
Join date : 2014-09-11
Location : Australia

http://www.nevyns-lab.com

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Tue Nov 12, 2019 7:22 pm

.
Thanks, DoubleSide makes both the cylinders and torus look better.

Animate the PI = 4 experiment - Page 5 Spotli10
A spot light from above.

Nevyn wrote.  Try using a SpotLight.
Copy that. My first effort at including a spot light is included. You can’t tell from this image, the spotLight helper shows the light is directed at the center of the circular track. This first ‘opportunity’ for learning lights has been more fun than I’d expected.

With respect to the spot light, it's a bit slow at present. The: position, intensity, angle, no problem. I haven’t pointed it reliably yet, let alone at a moving target. The world and the group coordinates are off a little, allowing coordinate simplicity and orbital camera ease.  

I’ll keep at it.
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by Nevyn on Tue Nov 12, 2019 8:45 pm

I was thinking that the spot light would be inside the ball. Like head-lights on your car.
Nevyn
Nevyn
Admin

Posts : 1796
Join date : 2014-09-11
Location : Australia

http://www.nevyns-lab.com

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Wed Nov 13, 2019 7:29 pm

.
Animate the PI = 4 experiment - Page 5 Frontb10
The track's top and bottom views.

Understood. Spotlights inside the spheres, acting like car headlights. I usually post regularly, wherever I am. Yesterday, I could only manage pointing a stationary spotlight at (0,0,0).

After that post and a few more hours frustration I found the answer to my question.
spotlight-cant-set-target-correctly
https://discourse.threejs.org/t/spotlight-cant-set-target-correctly/3674
That reference includes an interesting horizontal spotlight that might make a good spinning emergency vehicle light - or a rolling particle (?).

Apparently the spotlight, spotlight.position and spotlight.target all must be global variables which are added to the scene and updated in the animation loop.

I installed the spot light in the sphere on the straight track. The sphere in the curved track still has the internal point light. There’s also an ambient light, and a point light also in the straight track sphere.

Why does the bottom of the track look so much nicer than the top?
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by Nevyn on Wed Nov 13, 2019 8:22 pm

You don't want to use the target property. That is used to make the light point at that target, but you don't have a target to follow.

You should be able to put the light into a Group that contains the ball, but is higher than where the rolling rotation is being applied. If you don't have one, create one. That is, the Group is used to move the ball along the track, while a lower Group (or maybe even the sphere itself) is rotated based on the rolling action. This allows the light to move along with the ball, but is not rotated with it. However, you do need the rotation from the curved track to be applied to that higher level Group, so that the light always points along the track (i.e. forward). You may need to separate out some objects to accomplish this.

The bottom of the track may look nicer because of the way the light is pointing. It may not be symmetrical along the track axis.
Nevyn
Nevyn
Admin

Posts : 1796
Join date : 2014-09-11
Location : Australia

http://www.nevyns-lab.com

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Thu Nov 14, 2019 7:24 pm

.
Animate the PI = 4 experiment - Page 5 Sphere11

You don't want to use the target property. That is used to make the light point at that target, but you don't have a target to follow.
Woe’s me to disagree, so I led with the image above. spotlight.target works fine. spotLight.position and spotLight.target are both advanced by using sphereC’s trackAngle position. Here’s most of the curved loop portion of the animate function (excluding the pi switch lines).  

Code:

     else if (( distNextC >= cTracSectK ) && ( distNextC < cTrackLengthK )) {
          // pi switch stuff omited
          var trackAngle = numerator/denominator;
          sphereC.position.set( r*Math.sin( trackAngle ), 0, r*Math.cos( trackAngle ));
          pointLightC.position.set( r*Math.sin( trackAngle ), 0, r*Math.cos( trackAngle ));
          spotLightC.position.set( r*Math.sin( trackAngle ), 0, r*Math.cos( trackAngle ));
          spotLightC.target.position.x = r*Math.sin( trackAngle + Math.PI/3 );
          spotLightC.target.position.z = r*Math.cos( trackAngle + Math.PI/3 );
          sphereC.rotation.y = trackAngle;
          distTraveledC = distNextC;
          curSectionC = nexSectionC;
     };

ballOne (or ballTwo) is a 3D object. sphereC is a mesh that is added to ballOne. ballOne (or.  ballTwo) is added to the group, grp. grp is added to the scene. Have I screwed up wrong or right? Can we add point lights at the sphere’s north and south poles?

Animate the PI = 4 experiment - Page 5 Sphere10
PI = 4 Experiment. Lights. At present, each sphere moves along with: 1) a point light – a tiny sphere at the center of the yellow spheres; 2) a point light helper - tight wireframe octahedron; 3) a spot light and 4) a spot light helper - the wireframe ‘headlight’ which indicates the extent and direction of the spot light beams. Along the curve, the beam is directed at a constant angle trackAngle + Math.PI/3. In the main image, the tracks are lit up by an ambient white light at the default intensity of 1. The ambient light for the two inset loops is 2.5.

After some effort at playing with the spotLight I found it made small difference through the curve. The pointLight is much more effective. The opposite is true along the straightaway, where compared to the pointLight, the headlight is more effective at illuminating the walls along the straight tracks.
 
Notice the 'bottom' of the torus's most distant side in the image at the top. I flipped the track torus and cylinders - top and bottom – and found I was able to reverse the colors from the image I posted last time. Akin to application of a reflective or on half of the inside walls, top or bottom. Seems like a property but i haven't looked.
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Fri Nov 15, 2019 7:24 pm

.
Animate the PI = 4 experiment - Page 5 Badspi10
Of course I had to try adding north and south pole point lights. The image shows the results. The red and blue pole pointLights remain at the poles for sphereS in the straight track at the top. Not so for the pole lights for the curved track sphere sphereC, the roll matches that of sphereS.

The pole lights for the curved path sphereC continue spinning with the initial z axis roll. The center of sphereC moves around the curved track as per the trackAngle. sphereC’s pole lights need one more rotation – the rotation of the spheres about its y axis, equal to the track angle.

Nevyn, I hope I haven't offended you. I earnestly wish to learn how to do these things more efficiently. As a rule, I do not ignore your directions, if anything, I’m routinely guilty of plain old misunderstanding.  
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Sat Nov 16, 2019 7:29 pm

.
Animate the PI = 4 experiment - Page 5 Tubewa10
Attempting to replace the wireframe spheres with a new sphere material.

Both sphere’s pole point lights are now rolling correctly. I used an axis angle operation. Here’s the changes to the same animate frunction loop section I posted last Thursday.

Code:

      // pi switch stuff omited
 var trackAngle = numerator/denominator;
 var sphereCenterPoint = new THREE.Vector3( r*Math.sin( trackAngle ), 0, r*Math.cos( trackAngle ) );
 sphereC.position.set( sphereCenterPoint.x, sphereCenterPoint.y, sphereCenterPoint.z );
 pointLightC.position.set( r*Math.sin( trackAngle ), 0, r*Math.cos( trackAngle ));
 var sphereAxis = new THREE.Vector3( 0, 1, 0 );
 var northRoll = new THREE.Vector3( ptLtPos*Math.sin( sRotation ), ptLtPos*Math.cos( sRotation ), 0 );
 northRoll.applyAxisAngle( sphereAxis, trackAngle );
 var southRoll = new THREE.Vector3( ptLtPos*Math.sin( sRotation + Math.PI ), ptLtPos*Math.cos( sRotation + Math.PI ), 0 );
 southRoll.applyAxisAngle( sphereAxis, trackAngle );
 var northVector = new THREE.Vector3( sphereC.position.x + northRoll.x, sphereC.position.y + northRoll.y, sphereC.position.z + northRoll.z );
 var southVector = new THREE.Vector3( sphereC.position.x + southRoll.x, sphereC.position.y + southRoll.y , sphereC.position.z + southRoll.z );
 pointLightCN.position.set( northVector.x, northVector.y, northVector.z );
 pointLightCS.position.set( southVector.x, southVector.y, southVector.z );
 spotLightC.position.set( r*Math.sin( trackAngle ), 0, r*Math.cos( trackAngle ));
 spotLightC.target.position.x = r*Math.sin( trackAngle + Math.PI/3 );
 spotLightC.target.position.z = r*Math.cos( trackAngle + Math.PI/3 );
 sphereC.rotation.y = trackAngle;
 distTraveledC = distNextC;
 curSectionC = nexSectionC;

You indicated there usually isn’t a good reason for a final wireframe object. Now seemed like a good time to try a transparent sphere; like I did with boids. I tried transparent Lambert and Phong spheres so as to be able to enjoy the rolling motion. Unfortunately, the spheres blink in and out of view – depending on the angle of view. When out, the center and two pole point lights are perfectly visible rolling along. Oh well, I certainly enjoyed the excersize in including them, I won’t feel obliged to keep them there. But I do want anyone to be able to get a good view of the rolling action and that requires more that a featureless surface.
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Sun Nov 17, 2019 6:15 pm

.
Animate the PI = 4 experiment - Page 5 Quadsp10
As shown, the straightaway particle rolls only about it z-axis. In addition to the z-roll, the curved path particle must also rotate about its y axis.

You indicated I should change my object structure, I believe I’ve made progress. Here’s the latest changes to the section I posted last time.
Code:

// pi switch stuff omited
var trackAngle = numerator/denominator;
var sphereCenterPoint = new THREE.Vector3( r*Math.sin( trackAngle ), 0, r*Math.cos( trackAngle ) );
ballOne.position.set( sphereCenterPoint.x, sphereCenterPoint.y, sphereCenterPoint.z );
ballOne.rotation.y = trackAngle;
spotLightC.position.set( r*Math.sin( trackAngle ), 0, r*Math.cos( trackAngle ));
spotLightC.target.position.x = r*Math.sin( trackAngle + Math.PI/3 );
spotLightC.target.position.z = r*Math.cos( trackAngle + Math.PI/3 );
distTraveledC = distNextC;
curSectionC = nexSectionC;

The animate function now advances ballOne instead of sphereC. sphereC is still added to ballOne, the point lights and new set of three grommets are now also added to ballOne in the init function.

I haven’t attempted to move the spotlights yet. I also want to install rear direction spot lights and four more point lights. I suppose I can add a larger transparent sphere to remove any possible bumps and improve the final product’s visual appeal through some phong adjustment.
 
Hard to tell with just a single view, but I think the spheres look good and they show rotations well. Having no desire for some sphereical texture like a favorite celestial body or an eyeball, would I need to create a local server in order to do so? I would rather come up with geometric features. At first I tried making hemispheres and the like from spherical buffer geometry without any success whatsoever, and no idea why - save for the Muses. All the better to find a ‘grommet’ solution that looks quite distinctive and goes well with the curved track’s quartertrack markers – see what I mean?
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by Nevyn on Mon Nov 18, 2019 6:05 pm

I feel like using the target property for the light is wrong. Yes, it works, but that doesn't mean it is the right way to get it to work. However, the alternative is complicated because it requires setting up the scene graph in the right way and then requires the rolling motion to be handled in a special way. Using the target property as you are does not really produce the strictly correct angling. The light is pointing towards the inside of the circle, like a car that is drifting instead of driving around the curve. However, that isn't a big issue.

The balls should not be transparent. Only the tubes because we need to see through them to see the balls.

In order to use textures, yes, you need to run it in a server with special permissions (which require some advanced web server administration), although if it is being served from the same place as the app, then those permissions are not needed. However, you can refer to the textures on my site because I have setup those permissions. It is fine if you don't want to use them, but they do make a really nice touch.

I am a bit concerned about statements like this:

Code:

spotLightC.position.set( r*Math.sin( trackAngle ), 0, r*Math.cos( trackAngle ));

Not because it is wrong, exactly, but it looks wrong. If I found this app, and looked over the code to see if it is valid, and found that statement, then I would assume the whole premise is wrong and PI does not equal 4. Why? Because that statement uses PI=3.14. Any time you are using trig functions, you are using 3.14.

Now, it isn't wrong, because it is the calculation of trackAngle that uses PI=4, and that value is setting the distance around the circle, but most people won't see that distinction. You would have to make that argument, assuming that you were even given the opportunity to argue it. Most would not give you that opportunity because they want this to be wrong. We are on the back foot on this one and don't need to be giving ammunition to the other side.

The main reason I don't like it, though, is because it is not based on motion. It is based on trigonometry. It might give you the right answer, but it doesn't do it in the right way. Remember every time your math teachers told you it isn't about getting the right answer, it is about how you got it? This is what they meant.

The math you are using is based on a circle. The ball moving around the track is not based on a circle. Effectively, what that math is doing is equivalent to the ball reaching the curve, shooting a tether to the center of the circle, and letting that tether pull it around the curve. The real ball, however, is pushed around the curve because it meets resistance to its intended path. One is from the inside and one is from the outside. They both achieve the same motion, but one represents reality while the other does not.

I can't figure out if this matters enough to worry about. I would do it based on motion because that represents the problem. That creates an app that is harder to refute because it operates in a more direct manner. However, visually, they create the same animation. I'm not even sure that the math would end up that different anyway. The same position needs to be calculated, the circle still needs to be taken into account, so they might end up very close anyway. I am more inclined to worry about getting it looking good and fit into a page for publishing.
Nevyn
Nevyn
Admin

Posts : 1796
Join date : 2014-09-11
Location : Australia

http://www.nevyns-lab.com

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by LongtimeAirman on Mon Nov 18, 2019 7:25 pm

.
Animate the PI = 4 experiment - Page 5 Bacand12
Today’s images include low ambient and downward directional lighting, showing how nine separate lights within each sphere illuminates more than a 2*r portion of track (the circular track’s centerline diameter).

The spheres are traveling through ‘transparent tubes’ and so they are never observed ‘directly’. I suppose that might make a specific visual product more or less difficult to achieve. I just started learning the subject. Do you have any comments, suggestions or recommendations you require or would like to see? Please pardon my earlier texture comment, of course if you directed me to use textures I would gladly comply. Shaders might be an option, any thought about that?

I feel like using the target property for the light is wrong
I made a change which may correct that a bit; the code line you quoted is gone. I created a new variable – ballMesh*. All the individual objects making up each sphere is first added to ballMesh. ballMesh is then added to the 3D objects ballOne and ballTwo. Eliminating those two spotlight positions in that animate loop section. That still leaves the spotlight targeting alongside advancing ballOne and ballTwo.

I should mention, about the spacebar option, holding down to advance the motion, releasing to stop motion. I noticed that a single press and release of the spacebar counts as two frame advances. Works fine if you’re aware of it, till you need finer control such as changing the rolling increments on the control panel. I would expect we need some controls. You know the constraints and the big picture.

I’m running out of ideas and tasks, what’s next? Do you have site requirements?

Reading your most recent post - the app may look and work correctly; its objectionable because of its use of geometric pi? True, the application is simple, I though it was based on rate*tine=distance, it certainly isn't based on force equations. Geometric pi is a tool. We recognize the limits of the tool, not just reject the tool for subjective reasons. I'll try to understand your comment better.

*ballMesh contains: 2 concentric spheres (solid yellow and slightly larger transparent); three mutually orthogonal rings; and nine different colored lights. Six point lights at the ring intersections, and another point light and two spotlights (forward and backward directed) at the center.

Animate the PI = 4 experiment - Page 5 Bacand11
Close to the 8*r marker, both particles are almost back in y-synch.
.

LongtimeAirman
Admin

Posts : 1461
Join date : 2014-08-10

Back to top Go down

Animate the PI = 4 experiment - Page 5 Empty Re: Animate the PI = 4 experiment

Post by Sponsored content


Sponsored content


Back to top Go down

Page 5 of 9 Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum