Comments (5)
I think you have some good ideas on one way to proceed. It is very valuable for the project that you are actually using it for something.
The memoization is sort of elegant, in that everything is calculated lazily. (Caching is not always beneficial, though. There is some lower limit where recalculating things is faster. Of course they can be combined too.)
Instead of "guessing" the dependent objects, they could be supplied in an array as second parameter to the memoize method. Simpler and more generally applicable.
There is a misconception about Ship.designState that it is supposed to be a dynamic object representing the actual state of the ship. My intention is that the design state is part of the ship specification, representing a "typical" setup (typical load configuration etc.), suited for some calculations/considerations (the role of certain given calculationParameters like draft and cb is a bit unclear, as they can be calculated from the hull and loads). For simulation scenarios, on the other hand, we should use one or more actual states.
I admit that I have not been great at marking the lines properly. I was the one to put object positions and "existence" in the ShipState class. Logically, some objects should be tightly bound to the ship itself, and I really think we need to solve that.
Regarding state properties that may change often, we must make sure that the amount of recalculation (of expensive calculations) is kept at a minimal, sufficient level.
(This potentially also applies to weight and Cg calculation on the ship, and some others which could conceivably be modified incrementally upon position/mass changes of parts. This becomes an issue once the number of parts grows, and could certainly be alleviated by a tree structure (which we have intentionally avoided to not lock ourselves to one so-called "taxonomy").)
I think we can have a type of simulation setup where a "ship simulation entity" is added to a simulation with an initial state, that could in some cases even be the design state (maybe by default). Then the simulation keeps the actual state separate from the ship object, and supplies it as parameter for calculations. This is the way I have intended the ship object calculations to be used. Calculations of interaction with the environment belong naturally on the "ship simulation entity". I also believe that fast-changing variables belong in that object. The "ship simulation entity" may well be an instance of an extended ShipState class.
I have not looked at all the code in your marsim project, or tested it. it looks really interesting, though. if you can get rid of the cluttering of the design state, and instead operate on an "actual state", it will be easier to convince me that you are doing the right thing.
from vesseljs.
getFuelMass should take a shipState parameter, and use that rather than the design state. I leave to you to correct that, because you are working on dependent code.
from vesseljs.
And maybe we should move the "design speed" and some other properties that don't make sense in a dynamical state to a separate object within the ship object. Maybe something like "design assumptions".
from vesseljs.
The design assumptions/criteria could also be separate from the ship specification and ship object. Then they could even be used (e.g.) as target for an optimizer that modifies the ship object to approach the given properties.
Keeping them separate from the specification is cleaner, and facilitates doing calculations with different assumptions without really modifying the design.
from vesseljs.
@icarofonseca It's about time for you to establish a good standard for the state / cache, specially if you are going to play with real time data from digital twins. A simple and efficient example would be good (e.g. parsing and recording data from the camera to the vessel).
from vesseljs.
Related Issues (20)
- Organizing Equipment, Lines and Dynamical Matrices HOT 2
- InsertMooring general function snippet HOT 2
- Modernizing with ES6 classes, modules and smarter build process HOT 3
- Fix caching, or disable, as proposed in #87 HOT 1
- Examples: Reduce camera range to improve depth resolution
- Duplicated code HOT 1
- Compatibility for THREE.js r118 HOT 2
- Bulkhead just reaching half the Breadth of Ship
- Is it possible to create a catamaran hullform with a wave piercer? HOT 1
- Adjustments on ES6 patterns HOT 5
- Publishing Vesseljs on npm HOT 2
- Adding "colors" to derived objects HOT 1
- Clickable objects in 3d, with editable info in the GUI HOT 3
- Scale and Rotation to Derived Objects HOT 5
- Idea for Envelope Hull HOT 1
- "Rugen-Kutta" should be "Runge-Kutta"... HOT 2
- Ship3D_v2 deck geometry error HOT 2
- undefined position gives NaN CG HOT 1
- New organization of project resources HOT 2
- Ship3D_v2.js in examples: e is not defined (shows in crane pendulum example)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vesseljs.