Possible Charged Particle Field

Page 22 of 24 Previous  1 ... 12 ... 21, 22, 23, 24  Next

Go down

Re: Possible Charged Particle Field

Post by LongtimeAirman on Mon Nov 12, 2018 6:45 pm

.

Added Colliding group scenarios, Ring UI and O Array UI, actually converting them from collision tests Direct 04 and Offset 03 into user interface scenarios. The Image shown is from O – or offset – Array UI.

I think we should have tabs with the first one being a description of the scenario and it will be showing by default.
Will do - I'll just need an example or reference in order to do so.
.

LongtimeAirman
Admin

Posts : 1080
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Tue Nov 13, 2018 2:20 am

I just pushed some changes to the UIManager to support sliders (range inputs) and dropdown boxes (selects). The sliders work just like the numbers, so you can use the min, max and step functions and you just add a range call in there too.

Code:

.control().id( 'count' ).message( 'Number of particles' ).range().value( 200 ).min( 2 ).max( 500 ).step( 1 ).add()

You can also use the more compact way by passing the min, max and step values into the range function:

Code:

.control().id( 'count' ).message( 'Number of particles' ).range( 2, 500, 1 ).value( 200 ).add()



To use a dropdown box, you must give it an array of values. If the array contains strings or numbers, then they will be used as-is, but you can also give it an array of objects where each object specifies key and text properties such that the user will see the text, but your code will receive the key.

Code:

.control().id( 'select' ).message( 'Select an option' ).options( [ 1, 2, 3 ] ).value( 2 ).add()

.control().id( 'select' ).message( 'Select an option' ).options( [ 'One', 'Two', 'Three' ] ).value( 'Two' ).add()

.control().id( 'select' ).message( 'Select an option' ).options( [
   { key: 1, text: 'One' },
   { key: 2, text: 'Two' },
   { key: 3, text: 'Three' }
] ).value( 2 ).add()

Notice that the last method to use a dropdown uses the key to set the value, not the text.

avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Tue Nov 13, 2018 3:53 am

Added a way to specify tabs.



Code:

ui.createForm().title( 'Gravity Scenario' )
   .tab( 'Overview' ).message( '<p>A 3D model of neutrons in a gravitational field. You can enter the number of particles to create and the radius of a sphere to place them in.</p>' )

   .tab( 'Parameters' ).message( '<p>Please enter some parameters for the model.</p>' )
   // add a control to specify the radius to position the particles in
   .control().id( 'radius' ).message( 'Radius to place particles' ).value( 100 ).min( 10 ).max( 1000 ).step( 10 ).add()
   // add a control to specify the number of particles
   .control().id( 'count' ).message( 'Number of particles' ).range().value( 200 ).min( 2 ).max( 500 ).step( 1 ).add()

   .tab( 'Tab 2' ).message( '<p>This doesn\'t actually do anything.</p>' )
   .control().id( 'select' ).message( 'Select an option' ).options( [
      { key: 1, text: 'One' },
      { key: 2, text: 'Two' },
      { key: 3, text: 'Three' }
   ] ).value( 2 ).add()

   // add the callback function
   .success( success )
   // show the dialog
   .show();

Each call to tab can then have a message to be placed above the controls. Any control created before the next call to tab will be put onto that tab. You must specify the title of the tab when you call the function to create it.

Note the use of HTML markup in the messages. I recommend at least using p tags to make things look nice on screen.
avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by LongtimeAirman on Tue Nov 13, 2018 4:35 pm

.
How nice to wake to an improved standard. Here's my effort to comply.


An easy change code wise, the hard part is constructing acceptable text. I don't see a need to change the parameter tab for Array UI, which I'll call the short title. The long title, Direct collisions - Array UI, is present on all three tabs. I imagine the short title (Array UI), and Parameters tabs will be standard across the Colliding group scenarios. Here, Lines/Target Boxes is a once only tab with additional Array UI information.

Confused? Comments, opinions and additional suggestions are always appreciated.

////\\\\\\\\//////

P.S. After reading all the information, I see I'll probably switch one or three user selected numbers in Array UI into range sliders.
.


Last edited by LongtimeAirman on Tue Nov 13, 2018 5:48 pm; edited 1 time in total (Reason for editing : Added P.S.)

LongtimeAirman
Admin

Posts : 1080
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Possible Charged Particle Field

Post by LongtimeAirman on Wed Nov 14, 2018 5:11 pm

.

Lattice Array UI tabs.

1. Sliders are now included in Array UI.

2 & 3. Tabs and sliders are now included in Lattice Array UI and Ring Array UI.

Lattice UI requested five numbers, a long list, so I broke the standard for a day, the scenario Parameters tab into two value entry tabs - Lattice dimensions and Velocities.

I spent way more effort than that, but nothing else went smoothly, that awful spin assignment is proving just plain awful and I misplaced one of the scenarios - I’m sure it will show up fine and dandy. I’ll take a few hours break first.
.

LongtimeAirman
Admin

Posts : 1080
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Wed Nov 14, 2018 6:58 pm

The Lattice X dimension particle count plus one. 2 to 6.

Is the user setting the particle count, or the particle count plus one? They should be setting the particle count. Don't make them perform mental gymnastics to figure out what they are doing.

Should the last lattice dimension be Z?

Is the tab title correct? Are they setting lattice dimensions or are they setting particle counts? Try to be clear in what the user is doing, not what you are doing with what the user gives you. Maybe just a title of 'Particles' would be sufficient.

Do they need to show the min/max values in the field title?

Change tab title 'Lattice UI' to 'Overview' as all scenarios should use the same title for that first tab. The title of the dialog box is specific to the scenario, but the first tab is to tell the user what they are about to see.
avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by LongtimeAirman on Wed Nov 14, 2018 11:20 pm

.
That was a good break. I completed my first run through of the Colliding group. Offset 04 and Spin 01 are all that's left - but I don't have any idea what to do about them yet.  Your comments helped, thanks, I answer them below. One issue, I found a new Offset array bug which shows as a backward trajectory in the center of the array - it should take a moment to fix ... as soon as I find it, that is.
 
The Lattice X dimension particle count plus one. 2 to 6.
…. Don't make them perform mental gymnastics to figure out what they are doing.
Airman. Agreed. I corrected the problem by introducing a new variable – latX.
var edgeX = latX + 1;

Should the last lattice dimension be Z?
Airman. Affirmative, corrected.

Is the tab title correct? Are they setting lattice dimensions or are they setting particle counts? Try to be clear in what the user is doing, not what you are doing with what the user gives you. Maybe just a title of 'Particles' would be sufficient.
Airman. Using the new variable latX, The tab Lattice dimensions is now correct.

Do they need to show the min/max values in the field title?
Airman. I don’t understand the question. The initial/final values are shown on the right side of the integer sliders.

Change tab title 'Lattice UI' to 'Overview' as all scenarios should use the same title for that first tab. The title of the dialog box is specific to the scenario, but the first tab is to tell the user what they are about to see.
Airman. Done.

With your permission, I'd like to clean up the Two, Three, and Four Body groups by installing UIs there next.
.

LongtimeAirman
Admin

Posts : 1080
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Wed Nov 14, 2018 11:42 pm

Airman wrote:Airman. I don’t understand the question. The initial/final values are shown on the right side of the integer sliders.

I'm talking about the field titles (set with the message function on a control):
  First velocity, 0 to 60.

I don't think the bold part is necessary. Also, don't put a full stop at the end, if you want something, then use a colon ':'.

Yes, do any others that you want to and it makes sense to have a UI. Leave the gravity scenario as I am using that for my testing of the UI and to show you how to use it. We will do that last.
avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by LongtimeAirman on Thu Nov 15, 2018 7:59 pm

.

Two Body UI.

I thought I’d put together Two, Three and Four Body UIs, but I stopped at the Two Body; the tabs are shown. I want to include particle orientation too, but there isn't much room. Two Bodies can easily fill three tabs, is that our standard limit? If so, we need to increase it. Three Bodies needs another tab or two; Four Bodies maybe more. These data entry blocks are large, is there any way to condense them?
.

LongtimeAirman
Admin

Posts : 1080
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Thu Nov 15, 2018 8:34 pm

You can have as many tabs as you want, but it does get messy.

Yes, there is a way to make the controls a bit smaller, but I'm not sure how much it will help.

Edit js/utils.js
Alter lines 334, 350, 378 and 419 to include another CSS class:

Code:

grp.addClass( 'input-group' );

becomes

Code:

grp.addClass( 'input-group input-group-sm' );

Note that the object will not always be grp. Look for the input-group and replace with input-group input-group-sm.
avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by LongtimeAirman on Thu Nov 15, 2018 10:56 pm

.

Four 100% images comparing the original CSS class 'input-group' (a and c), with the new CSS class 'input-group input-group-sm' (b and d).

I couldn't tell the difference till I compared them side by side. The slider's up/down (y dimension) is slightly shorter in b and d. Assuming I changed the code correctly, I'll consider it a small improvement - worth keeping.
.

LongtimeAirman
Admin

Posts : 1080
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Thu Nov 15, 2018 11:40 pm

There is another CSS class that can be added to the dialog itself that will make it large or small. It only seems to effect the width though, not the height as far as I can tell. Making them wider will help the messages, which will use less lines to show the same text.
avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Fri Nov 16, 2018 7:19 am

I have created a couple of special controls that allow the user to enter a vector or an axis angle. This reduces the space requirements by using a single line for the X, Y and Z coordinates.



You create them just like a number or range control, but instead of calling the range function, you call vector or axisAngle.

Code:

.control().id( 'vector' ).message( 'A vector' ).vector( -10, 10, 1 ).value( [ 1, 2, 3 ] ).add()
.control().id( 'axisangle' ).message( 'An axis angle' ).axisAngle( -10, 10, 1 ).value( [ 1, 2, 3, 4 ] ).add()

In the success function, both vector and axisAngle will give you an array. Vector uses an array of length 3 and axisAngle uses 4. The 4th value in an axis angle is the angle, specified in radians. The vector component of an axis angle is normalized, so the values may differ from those specified in the number inputs but will represent the same direction.
avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by LongtimeAirman on Fri Nov 16, 2018 1:24 pm

.
The vector and axisAngle types help greatly.

I'm stuck - the new variables are titled the same as the new number types - ok; but they aren't declared in Gravity's: initRandom function, or the success function code.

This is how a number is declared.  var xCoord = Number( values.xCoord );

How do I declare vector or axisAngle in the success function?

This is my guess:
var particleLocation = Vector( values.particleLocation );
var particleOrientation = AxisAngle( values.particleOrientation );
var particleSpin = AxisAngle( values.particleSpin );

Sorry, I'm a bit shy making up code. Do you have a good source reference for this latest CSS, Bootstrap, Cloudflare, Popper, what-have-you info?
.

LongtimeAirman
Admin

Posts : 1080
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Fri Nov 16, 2018 3:47 pm

They are being used in the gravity success function, but only to print them to the console:

Code:

console.log( 'vector: ' + values.vector[0] + ', ' + values.vector[1] + ', ' + values.vector[2] );
console.log( 'axis angle: ' + values.axisangle[0] + ', ' + values.axisangle[1] + ', ' + values.axisangle[2] + ', ' + values.axisangle[3] );

If you wanted to convert them into a THREE.Vector3 or THREE.Quaternion, you would do this:

Code:

// vector
var v = new THREE.Vector3( values.vector[0], values.vector[1], values.vector[2] );
// axis angle
var axis = new THREE.Vector3( values.axisangle[0], values.axisangle[1], values.axisangle[2] );
var q = new THREE.Quaternion().setFromAxisAngle( axis, values.axisangle[3] );
avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Fri Nov 16, 2018 4:18 pm

I made the modal dialog box wider.

avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by LongtimeAirman on Fri Nov 16, 2018 4:38 pm

.
Thanks, if you've answered my question I fail to see it.

Here is the success function from the Gravity group's initRandom function.
Code:

 var success = function( values ) {
      // we can reference the values by their id specified on their control
       var radius = Number( values.radius );
       var count = Number( values.count );
       var particles = initRandomTest( radius, count, factory );
       var particleArray = new PIM.ParticleArray( particles );
       ui.setParticles( particleArray );
       console.log( 'vector: ' + values.vector[0] + ', ' + values.vector[1] + ', ' + values.vector[2] );
       console.log( 'axis angle: ' + values.axisangle[0] + ', ' + values.axisangle[1] + ', ' + values.axisangle[2] + ', ' + values.axisangle[3] );
 };

The success function passes ( radius, count, factory ); with the initRandomTest function. You may be console monitoring it, but as far as I can tell, success doesn't share or pass 'vector', it isn't defined. I understand vector and axisAngle are arrays of 3 and 4 numbers and therefore they cannot be the Number type as in, var count = Number( values.count ).

I would like var particleLocation to be a new data entry value of the vector type (? that's my question). Please place the variable vector - or better still, var particleLocation - in the success variable list; like between var count and var particles.
.

LongtimeAirman
Admin

Posts : 1080
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Fri Nov 16, 2018 5:35 pm

Code:

 var success = function( values ) {
      // we can reference the values by their id specified on their control
      var radius = Number( values.radius );
      var count = Number( values.count );
     
      // vector
      var v = new THREE.Vector3( values.vector[0], values.vector[1], values.vector[2] );
      // axis angle
      var axis = new THREE.Vector3( values.axisangle[0], values.axisangle[1], values.axisangle[2] );
      var q = new THREE.Quaternion().setFromAxisAngle( axis, values.axisangle[3] );
     
      var particles = initRandomTest( radius, count, factory );
      var particleArray = new PIM.ParticleArray( particles );
      ui.setParticles( particleArray );
 };

These values aren't passed in to initRandomTest because they are not needed by that function. I am only adding these controls to test them and show you how to use them. But they are just variables like any other, so you can pass them into whatever functions need them.
avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by LongtimeAirman on Fri Nov 16, 2018 5:56 pm

.
Sorry, I can be difficult, thanks for your patience. Of course the new variable isn't going into the Gravity scenario, I just wanted to see you declare a new variable of the vector type - appropriate to a CSS function. I was under the mistaken impression that I was dealing with some non standard CSS form value. I don't recall ever declaring a var = Number(); before, I've always used the numbers or names without a Number identifier.  
.

LongtimeAirman
Admin

Posts : 1080
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Fri Nov 16, 2018 6:20 pm

None of this has anything to do with CSS. I mentioned CSS earlier because that is how the dialog box and controls are styled (via Bootstrap CSS classes), but you won't see any of that in these functions. It is hidden by the UIManager class.

The Number function is just a way to make sure that you are working with a numeric value and not a string or object or whatever. This can be needed because JS is a weakly typed language, so a variable can point to any type of value. You can get some strange results if you have a string instead of a number, for example. It probably isn't needed in this case either, because we are using input type="number" controls, so they should already take care of making sure it is a number. Never hurts to make sure though.

I toyed with the idea of the UIManager just generating a THREE.Vector3 or THREE.Quaternion, instead of using an array, but I decided against it because the UIManager currently doesn't know about THREE, and I would prefer to keep them separate as long as I can. It makes it more re-usable for other projects.
avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Fri Nov 16, 2018 6:28 pm

Also note that there is no connection between a CSS class and a JS class. They are completely different things. A CSS class is really just the name of a style that is applied to any HTML element that specifies that name in its class attribute. For example:

Code:

<div class="myCSSClass">
   <p>This text will be styled by its parent element, through the myCSSClass style.</p>
</div>

The CSS class myCSSClass can then be associated with the styling information to be applied to that element. For example:

Code:

<style>
.myCSSClass
{
   width: 50%;
   font-style: bold;
   color: #f0d0c0;
}
</style>

CSS is very powerful and should be used for all styling in a HTML document. You won't need to worry about that in this project though.
avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by LongtimeAirman on Sat Nov 17, 2018 12:18 pm

.
No joy, several frustrating hours. Two Body UI has all variables, vector and axisangle ready. The problem is that there is no output when I switch from the three individual coordinate numbers: xCoord, yCoord, and zCoord - to the new 2nd particle coordinate vector - pCoords. The console shows pCoords has the correct values. I pushed my changes to Bitbucket so it's current. I'll keep at it, but I'd be grateful if you give it a look.
.

LongtimeAirman
Admin

Posts : 1080
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Possible Charged Particle Field

Post by Nevyn on Sat Nov 17, 2018 3:26 pm

It was a bug in the UI code caused by not passing the value through the Number function, so each X, Y and Z were a string.
avatar
Nevyn
Admin

Posts : 1399
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Possible Charged Particle Field

Post by LongtimeAirman on Sat Nov 17, 2018 9:48 pm

.
Thanks for clearing up the latest. I'm back up to slow speed - in the middle of the axis angle change. I failed to mention it recently - avoiding the attention - the air quality here has been awful.

I like your code improvements in Two Body UI; the var a = spinVel*Math.PI/2, and the if/else if/ else if from inside the particle factory smacks of production efficiency and elegance. All the rest may be beyond me, but is nevertheless well appreciated, especially when you make it look easy.

I didn’t commit the small integer slider height reduction ( 'Alter lines 334, 350, 378 and 419' ), I overlooked it in my latest Push. I'll correct it next time.
.

LongtimeAirman
Admin

Posts : 1080
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Possible Charged Particle Field

Post by LongtimeAirman on Sun Nov 18, 2018 1:09 am

.
Nevyn wrote. Airman, a friend at work has been having trouble with SourceTree (not the same as you) and has started using a different GIT app called Fork. It is fairly similar to SourceTree, so I thought you might want to give it a go and see if you like it. I might start using it at home too.

I'm ready to try. My last Fetch, and Push a little while ago took over an hour with many fatal exceptions, log-ins and password entries.

Is this the application to which you are referring? https://www.fork-cms.com/. Are there any apps or mods I should be looking for?
.

LongtimeAirman
Admin

Posts : 1080
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Possible Charged Particle Field

Post by Sponsored content


Sponsored content


Back to top Go down

Page 22 of 24 Previous  1 ... 12 ... 21, 22, 23, 24  Next

Back to top


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