physics-engine

Generate mesh and refine mesh of triangles

*爱你&永不变心* 提交于 2021-02-08 10:24:07
问题 I need to find a way to mesh triangles then to refine using refine. My vertices of my original triangles are stored inside a matrix of size nb_points * 2. My faces are stored in a nb_faces * 3 matrix. The data for each face is stored in a nb_face * 1 matrix. The meshing is done by diving the area using the middles of the segments of the triangles. Example : Origin : vertices = [0 1 ; 2 3 ; 4 1 ; 4 5]; faces = [1 2 3; 2 3 4]; data = [1 2]; Result expected after meshing : vertices = [0 1; 2 3;

Numerical integration: Why does my orbit simulation yield the wrong result?

我的未来我决定 提交于 2021-01-28 18:01:42
问题 I read Feynman's Lecture on Physics Chapter 9 and tried to my own simulation. I used Riemann integrals to calculate velocity and position. Although all start-entry is same, my orbit look's like a hyperbola. Here is lecture note: https://www.feynmanlectures.caltech.edu/I_09.html (Table 9.2) import time import matplotlib.pyplot as plt x=list() y=list() x_in=0.5 y_in=0.0 x.append(x_in) y.append(y_in) class Planet: def __init__(self,m,rx,ry,vx,vy,G=1): self.m=m self.rx=rx self.ry=ry self.a=0 self

Matter.js: placing text or images on the canvas

怎甘沉沦 提交于 2020-08-27 22:15:49
问题 I'm wanting to place font or static images onto the canvas but not sure what the best approach is using Matter.js. Right now, for images, i'm just creating a body with a size of '0' and putting the image url in the render.sprite.texture property. Seems to do the trick but is there a different/better way of putting static images on the canvas? Also, I am putting text onto the canvas using the 'afterRender' event near the top of my scripts, before anything else is created/drawn: _sceneEvents

Matter.js: placing text or images on the canvas

a 夏天 提交于 2020-08-27 22:15:15
问题 I'm wanting to place font or static images onto the canvas but not sure what the best approach is using Matter.js. Right now, for images, i'm just creating a body with a size of '0' and putting the image url in the render.sprite.texture property. Seems to do the trick but is there a different/better way of putting static images on the canvas? Also, I am putting text onto the canvas using the 'afterRender' event near the top of my scripts, before anything else is created/drawn: _sceneEvents

How to handle multiple simultaneous elastic collisions?

一曲冷凌霜 提交于 2020-02-26 10:05:09
问题 I'm computing the result by colliding pairs of 2D convex objects (without rotation), using the basic equations on wikipedia. However, when there are dependencies, like two objects hitting another object at the same time: Such as here, with objects 1 and 2 hitting 3 at the exact same time, the pair-wise approach fails. Depending on the order I compute the collisions (1-3 first or 2-3 first), I will get different results. Repeated iteration through the collisions will still give order dependent

How to handle multiple simultaneous elastic collisions?

只谈情不闲聊 提交于 2020-02-26 10:04:25
问题 I'm computing the result by colliding pairs of 2D convex objects (without rotation), using the basic equations on wikipedia. However, when there are dependencies, like two objects hitting another object at the same time: Such as here, with objects 1 and 2 hitting 3 at the exact same time, the pair-wise approach fails. Depending on the order I compute the collisions (1-3 first or 2-3 first), I will get different results. Repeated iteration through the collisions will still give order dependent

Is there an upper limit on velocity when using box2d?

坚强是说给别人听的谎言 提交于 2020-01-19 15:40:53
问题 I'm using box2d for physics simulation. I'm moving a circle using arrow keys by applying impulse on the body when ever a key is pressed. Unfortunately, the circle moves excruciatingly slow and doesn't seem to accelerate like a true physical body is supposed to. My world's dimensions are 400x800 pixels. The radius of the circle body is 20f. According to this, the problem can be solved by scaling the circle radius down when creating it and scaling up after getting the body position during

how to control the speed of animation, using a Bezier curve?

你。 提交于 2020-01-16 02:50:47
问题 I found formula only for vector coordinates of cubic curve who help in depicts(build vector image). Here it is: B(t) = (1-t)^3*P0 + 3*t*(1-t)^2*P1 + 3*t^2*(1-t)*P2 + t^3*P3 See more at: http://www.ams.org/samplings/feature-column/fcarc-bezier#sthash.85XhcT7H.dpuf This formula returns the coordinates of the vector, but I can not understand how they can influence the speed of the animation, as in http://cubic-bezier.com/#.17,.67,.83,.67. Please, direct me to the right way so that I could

Speed of C++ operators/ simple math

拜拜、爱过 提交于 2020-01-06 05:00:09
问题 I'm working on a physics engine and feel it would help having a better understanding of the speed and performance effects of performing many simple or complex math operations. A large part of a physics engine is weeding out the unnecessary computations, but at what point are the computations small enough that a comparative checks aren't necessary? eg: Testing if two line segments intersect. Should there be check on if they're near each other before just going straight into the simple math, or

fast dirty approximation of center of (list of 3D vertex) that forms a very shallow convex hull

寵の児 提交于 2020-01-04 14:16:40
问题 I want to find XY of the center (red) of a convex-hull points (orange circles) set that is a result from collision detection. Using separating-axis technique, I know for sure that the convex shape (pink) is relatively thin in Z-axis . In >90% of my use cases, the amount of vertices is not more than 8. My poor algorithm (AABB) ... MCVE I tried to implement it by calculating the center point of AABB. However, when I use it in real Physics simulation, the collision point (red) is not accurate