-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simultaneous attractive and repulsive forces in the same particle #85
Comments
A simple patch would be to revert the sign in an else condition.
from my experience, any rule that apply to the whole screen (r > radius*radius) lead to uninteresting result. |
But I don't want to apply the rules to the whole screen. I think I misunderstood part of the code. |
Do you have any idea how to make settings menu with vertical scrollbar? When you have a lot of data in the menu, you need to be able to scroll through it to view it. I'd like to do that but I don't know how. |
I don't know. I made gui group instead. |
I don't understand this part of the code. This is where the problem with the strange behaviour of the particles comes from. Please, could you help me?
|
Try with this (doing comparison with the distance squared was a dirty optimization trick that may not even worth it). for (auto j = 0; j < group2size; j++)
{
const auto& p2 = (*Group2)[j];
// you don't need sqrt to compare distance. (you need it to compute the actual distance however)
const auto dx = p1.x - p2.x;
const auto dy = p1.y - p2.y;
const auto r = std::sqrt(dx * dx + dy * dy);
//Calculate the force in given bounds.
if ((r > (Gradius - Aradius) || radius_toggle) && r != 0.0F)
{
fx += (dx / r);
fy += (dy / r);
}
}
//Calculate new velocity
p1.vx = (p1.vx + (fx * (g + a)) * (1 - viscosity));
p1.vy = (p1.vx + (fx * (g + a))) * (1 - viscosity) + worldGravity; |
I noticed that changing the parameters of the interaction forces has no effect on what happens on the screen. This means that those parameters are not taken into account. But how should it be correct? |
I got stuck. I don't know what to do. |
wait, how old is the code you're using as a base ? Also : |
I don't know how old. I downloaded with the last modification. With r < Gradius, I gain: With r < Gradius * Gradius I gain: |
well my bad. I'm so busy playing with my oneapi branch that I forgot to do some merge request here. you have the last code indeed ^^ |
It can be seen that the forces acting on the screen are not those resulting from the parameters. There are other forces on the screen that move and keep the particles aligned that are much stronger than the forces resulting from the parameters defined by those sliders. So, the formulas for calculating forces and velocities do not take into account the powerSlider and vSlider parameters. |
There is something super weird, even in my code. |
ha yes I see... "attraction" is named "gravity"... (which is kind of bad since there is a world gravity parameter) |
random guess. can you try with std::abs(Gradius - Aradius) ? |
However, I think this code should be rewritten from scratch and rewritten taking into account what is written in this document. Romanian Adrian Ferent from the University of Bucharest has some very interesting findings on dark photons, dark matter, dark energy, Planck's wall and Ferent's wall, gravitons and elementary particle theory. From here I would like to implement some ideas. https://independent.academia.edu/ADRIANFERENT I can say that this Romanian professor is a true genius. |
Hi! I want a particle of a certain colour to attract and repel a particle of another colour simultaneously, on different beams and with different intensities. In the original application, a particle either attracts or repels another particle, depending on the sign of the intensity of the interaction force.
I started by defining interactions as follows:
void interaction(std::vector* Group1, const std::vector* Group2, float G, float Gradius, float A, float Aradius, float viscosity, float Gprobability, float Aprobability);
"G" would be "powerSlider_a_" for pull force, "Gradius" would be "vSlider_a_" for pull force, "A" would be "powerSlider_r_" for repelling force, "Aradius" would be "vSlider_r_" for repelling force.
Defining interactions would be of the form:
if (numberSliderR > 0) interaction(&green, &red, powerSlider_a_GR, vSlider_a_GR, powerSlider_r_GR, vSlider_r_GR, viscosityG, probability_a_GR, probability_r_GR);
However, I have no idea how the calculation of forces and velocities should be defined.
I try to defined:
void ofApp::interaction(std::vector* Group1, const std::vector* Group2, const float G, const float Gradius, const float A, const float Aradius, const float viscosity, const float Gprobability, const float Aprobability)
{
const float g = G / -100; //Gravity coefficient
const float a = A / 100; //Anti-Gravity coefficient
const auto group1size = Group1->size();
const auto group2size = Group2->size();
const bool radius_toggle = radiusToogle;
But I don't know if it's good.
Then I modified this:
//Calculate the force in given bounds.
if ((r < (Gradius * Gradius - Aradius * Aradius) || radius_toggle) && r != 0.0F)
{
fx += (dx / std::sqrt(dx * dx + dy * dy));
fy += (dy / std::sqrt(dx * dx + dy * dy));
}
}
But I don't know if it's good.
It must be kept in mind that each type of force has its intensity and range of action and this must be clearly defined in the application.
There would be three situations:
when Gradius > Aradius;
when Gradius = Aradius;
when Gradius < Aradius.
For each of them I think the formulas for force and velocity should be defined.
For example: Blue can attract White with an intensity of 20, on a radius of 100, and at the same time repel White with an intensity of 30 but on a radius of 40. Then White can attract Blue with an intensity of 30 on a radius of 70, but simultaneously repel it with an intensity of 50 on a radius of 60. So White can be caught by the attraction of Blue but cannot approach it at less than 60, because it repels Blue with an intensity of 50 which is greater than the attraction of 30 it has to Blue at a radius of 70. At a distance of 60, there is a neutral force of zero intensity between Blue and White.
Any ideas? Any help?
The text was updated successfully, but these errors were encountered: