physics

Convert RGB to light frequency

南笙酒味 提交于 2019-12-19 02:55:13
问题 Is it possible to obtain the light frequency of a colour from a RGB representation? I've found the opposite process [1] but I don't know if it's possible this way. [1] http://www.fourmilab.ch/documents/specrend/ 回答1: AFAIK, there is no direct answer because multiple wavelengths can combine to give the same color right? So you have the wavelengths that map to pure colors and then their combinations can give many other and the same colors. And there are several combinations that can give the

N-Body Gravity Simulation in JavaScript

て烟熏妆下的殇ゞ 提交于 2019-12-18 10:37:49
问题 So, I am trying to create a N-Body Gravity simulation in JavaScript: http://jsfiddle.net/4M94x/ var Circle = function(c, r, cor, cof) { // Fix CoR & CoF // Had to add code for JSFiddle link :P this.c = c this.r = r this.m = r * r * Math.PI this.v = new Vector() this.cor = cor this.cof = cof } The problem's that when you spawn (click) and put 2 balls (accidentally renamed "particles") next to each other they start to generate velocity and faster and faster push eachother.. How do I fix this,

2d trajectory planning of a spaceship with physics

丶灬走出姿态 提交于 2019-12-18 10:24:50
问题 I'm implementing a 2D game with ships in space. In order to do it, I'm using LÖVE, which wraps Box2D with Lua. But I believe that my question can be answered by anyone with a greater understanding of physics than myself - so pseudo code is accepted as a response. My problem is that I don't know how to move my spaceships properly on a 2D physics-enabled world. More concretely: A ship of mass m is located at an initial position {x, y} . It has an initial velocity vector of {vx, vy} (can be {0,0

SKPhysicsBody avoid collision Swift/SpriteKit

元气小坏坏 提交于 2019-12-18 07:23:34
问题 I have 3 SKSpriteNodes in my Scene. One bird , one coin and a border around the scene. I don't want the coin and the bird to collide with each other but withe the border . I assign a different collisionBitMask and categoryBitMask to every node: enum CollisionType:UInt32{ case Bird = 1 case Coin = 2 case Border = 3 } Like so: bird.physicsBody!.categoryBitMask = CollisionType.Bird.rawValue bird.physicsBody!.collisionBitMask = CollisionType.Border.rawValue coin.physicsBody!.categoryBitMask =

Moving Node on top of a moving platform

倾然丶 夕夏残阳落幕 提交于 2019-12-18 02:57:44
问题 I have a moving platform, but when the node is above the platform it doesnt move with the platform horizontally In this article, the problem is explained: Moving Platform Hell http://www.learn-cocos2d.com/2013/08/physics-engine-platformer-terrible-idea/ And in comment there is solutions for Box2D: Kinematic body But what about SpriteKit ? Update I'm moving the platform using let moveHPart1 = SKAction.moveByX(origW, y: 0, duration: moveDuration); let moveHPart2 = SKAction.moveByX(-origW, y: 0,

Function for rotating 2d objects?

前提是你 提交于 2019-12-17 20:10:14
问题 Is it possible to write a function in python that could rotate any 2d structure with the arguments being only the coordinates (x,y) of the points in the structure? Additional arguments would be included for axis, speed and direction. To my understanding it would only be possible by calculating point distance from symmetrical points and the axis and therefore it would always vary and is thus impossible except for 2d structures made up of standard shapes (triangles, rectangles, squares etc)

applyForce(0, 400) - SpriteKit inconsistency

一个人想着一个人 提交于 2019-12-17 18:19:07
问题 So I have an object that has a physicsBody and gravity affects it. It is also dynamic. Currently, when the users touches the screen, I run the code: applyForce(0, 400) The object moves up about 200 and then falls back down due to gravity. This only happens some of the time. Other times, it results in the object only moving 50ish units in the Y direction. I can't find a pattern... I put my project on dropbox so it can be opened if anyone is willing to look at it. https://www.dropbox.com/sh

How to find trajectory path if the distance traveled, starting elevation, ending elevation and time in the air are known

跟風遠走 提交于 2019-12-17 17:14:39
问题 I'm trying to find the trajectory an object would take (assuming air drag is negligible and trajectory angle is always between 0 and 90), including peak height. Here's what I know: takeoff point latitude, longitude, elevation landing poing latitude, longitude, elevation distance traveled amount of time in the air For me the problem could be reduced to 2d space, so if an object travels a horizontal distance of 8 meters starting at an elevation of 0 and ending at a relative elevation of -5

Java heap space out of memory

做~自己de王妃 提交于 2019-12-17 05:00:57
问题 My application currently consumes quite a lot of memory because it is running physics simulations. The issue is that consistently, at the 51st simulation, java will throw an error usually because of a heap space out of memory (my program eventually runs thousands of simulations). Is there anyway I can not just increase the heap space but modify my program so that the heap space is cleared after every run so that I can run an arbitrary number of simulations? Thanks -edit- Thanks guys. Turns

How to calculate bounce angle?

妖精的绣舞 提交于 2019-12-17 03:22:52
问题 I played around with it for a while, but I simply can't figure it out. I made a tank that fires missiles, and when the missiles hit the walls, I want them to bounce off, but I want them to bounce off to the right angle. Right now I haven't got any obstacles, the missiles just bounce off when they get outside the viewportRectangle I made. Is the solution I'm looking for quite advanced? Is there a relativly simple way to do it? 回答1: I think an easier way to do this is to use the velocity of the