2d

Detecting light projections and intersections in 2D space using C#

▼魔方 西西 提交于 2019-12-14 02:35:24
问题 A light source is an entity in 2D space that sits in a single coordinate. There are multiple light sources around in various locations and each gives off 8 rays of light in directions N, S, E, W, NW, NE, SW, SE. The coordinates of all lights are known. I need to calculate all intersections of

How to determine +/- sign when calculating diagonal intersections between two points in 2D space?

£可爱£侵袭症+ 提交于 2019-12-14 01:27:44
问题 This is an offshoot of another question and has to do with Keith Randall's answer to the problem. Please do have a quick look at the image there to see what the function below is trying to do. In short, any two points on a 2D grid would have two diagonal intersections if x2 != x1 and y2 != y1 . I

Add a vector to a position

拟墨画扇 提交于 2019-12-13 20:11:34
问题 I have an object in 2D space whose position is (A, B) and which has an orientation (between 0 and 360). I have a distance, say D. I would like to add D to the object's position, in the direction that the object is looking toward. Mathematically, how would I go about doing that? Thank you. 回答1:

Get the upper, bottom, rightmost and leftmost point of a pixel-perfect BitmapData collision

非 Y 不嫁゛ 提交于 2019-12-13 18:11:04
问题 How can I get the upper, bottom, rightmost and leftmost point of a pixel-perfect BitmapData collision? This is my collision-detection code: public static function checkCollision(object1:*, object2:*, debug:Boolean = false):Boolean{ var object1Rect:Rectangle = object1.getRect(stage); var