编写物理模拟应用程序

发布于 2024-10-02 10:51:29 字数 367 浏览 6 评论 0原文

我是计算机编程新手,并且有一些使用 python 编程的经验。我正在考虑开发一个进行物理模拟(抛射体、圆周运动、阻尼简谐振动系统等)的程序作为业余爱好项目。我想编写一个程序,它可以由非技术用户(我的同学)在各种平台(mac、windows等)上运行,无需任何设置,而 python 似乎不是一个好的选择构建这样一个程序,所以我正在寻找替代方案。 JavaScript 引起了我的注意,因为它在现代浏览器上似乎非常强大,尤其是与 HTML5 结合使用时。我想知道这种类型的应用程序是否适合使用 JavaScript,以及一些关于我应该从哪里开始的信息(我没有 JavaScript 知识) 提前致谢!

是的,我确实看过网站上的类似线程,但我想自己写一些东西,而不是使用第三方库(除了前端,如果可能的话):)

I am new to computer programming and have some experience programming with python. I am thinking of developing a program that does physics simulations (projectiles, circular motion, damped simple harmonic motion systems etc.) as a hobby project. I would like to write the program that it could be run by a non-technical user(my fellow students) on a variety of platforms (mac, windows etc.) without any setup and python doesn’t seem to be a good option for building such a program so I am looking for an alternative. JavaScript has caught my attention, as it seems to be quite powerful on modern browsers, especially in conjunction with HTML5. I would like to know whether it is suitable to use JavaScript for this type application, and some information as to where I should start (I have no JavaScript knowledge)
Thanks in advance!

Yes I did have a look at the similar threads on the site but I want write something by myself than using a 3rd party library (other than for the frontend, if possible) :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情徒 2024-10-09 10:51:29

你的问题实际上是什么? :)

你能用 Python 编写物理模拟吗?
是的当然。

你能用 JavaScript 编写物理模拟吗?
是的。

有用吗?
是的,可能是。

效率高吗?
当然,不如用 C 实现那么高效。但是对于小规模的模拟,您应该拥有足够的能力来使用当前的 JIT javascript 解释器。我认为 30 fps 上的数十或数百个物体看起来是一个安全的近似值。

在 JS 中编写物理模拟时可以使用现代 HTML 吗?
模拟和显示是两个不同的东西,但是,是的,如果您想为模拟创建图形前端,HTML 和 CSS 的现代功能肯定会很有用。但如果您用任何其他语言编写它,您仍然有不错的可视化选择。

如何学习JavaScript?
网上有很多教程,但我不知道有哪一个可以推荐;也许其他人可以代替我在这里。

What is actually your question? :)

Can you write a physics simulation in Python?
Yes, of course.

Can you write a physics simulation in Javascript?
Yup.

Will it be useful?
Yes, probably.

Will it be efficient?
Not as efficient as an implementation with C, to be sure. But for small-scale simulations should you should have quite enough power with current JIT javascript interpreters. Tens or hundreds of objects on 30fps looks like a safe approximation, I think.

Can you make use of modern HTML when writing a physics simulation in JS?
The simulation and the display are two different things, but yes, if you want to make a graphics frontend to your simulation, the modern features of HTML and CSS could be certainly useful. But if you write it in any other language, you still have nice choices for visualization.

How to learn JavaScript?
There's plenty of tutorials online, but I don't know any particular one to recommend; perhaps anyone else can fill for me here.

乱了心跳 2024-10-09 10:51:29

正如 Kos 所提到的,像 Python 或 Javascript 这样的高级语言可能会限制你。但稍后您仍然可以将关键部分移至 C 代码。 (-> 常规共享库甚至浏览器插件)

对于 JavaScript,我向您推荐 Mozilla 教程: https:// /developer.mozilla.org/en/javascript
请特别查看“JavaScript 指南”,并记住并非每个浏览器都支持 JavaScript 1.7。顺便说一句,您还应该查看 jQuery。实际上,从 jQuery 开始可能更容易,因为无论如何您都需要一些高级库。

顺便说一句:您可能还想查看处理。 (www.processing.org) 它可能非常适合您,因为您是编程新手,并且它具有许多很棒的可视化功能。它基本上是一个简化的 Java,带有一个非常易于使用的库。您可以查看预安装的示例并开始尝试。如果您遇到问题,请务必检查网站/论坛上的参考资料。处理在 JVM 上运行,因此是跨平台的。
我非常推荐Processing,因为您可以直接看到结果,并且无论如何,即使您考虑将来使用另一种语言来满足您的需求,原型制作也可能很有趣。

实际上,甚至还有一个 JavaScript 版本的 Processing,尽管我从未使用过它...

编辑:如果您打算选择 JavaScript,您应该将 Firefox 与 Firebug 结合使用。它使调试时的生活变得更轻松......

As mentioned by Kos languages that are as High Level as Python or Javascript might constrain you. But later on you can still move critical parts to C-Code. (-> Regular shared Library or even Browser-Plugin)

For JavaScript I recommend you the Mozilla tutorials: https://developer.mozilla.org/en/javascript
Check out the "JavaScript Guide" in particular and keep in mind that not every Browser supports JavaScript 1.7. By the way, you should also checkout jQuery. Actually it might be easier to start right off with jQuery because you need some highlevel library anyways.

By the way: You might also want to check out Processing. (www.processing.org) It might be perfect for you as you are new to programming and it has a lot of awesome vizualization features. It basically a simplified Java with a very easy to use library. You can checkout the pre-installed examples and start playing around. Be sure to check the Reference on the website / the forum if you are stuck with problems. Processing runs on the JVM and is therefore cross plattform.
I recommend Processing very much because you can directly see results and in any case it might be interesting for Prototyping even if you think of using another language in the future to suit your needs.

Actually there is even a JavaScript version of Processing though I never used it...

EDIT: If you plan to choose JavaScript, you should use Firefox in combination with Firebug. It makes life easier when debugging...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文