Advertisement

Parallivity versus inverse square falloff

Started by January 27, 2024 06:46 PM
9 comments, last by JoeJ 10 months, 4 weeks ago

I am trying to mimic the inverse square falloff by taking into consideration how parallel the gravitons are that strike the receiving body.

In Newton's gravitation, acceleration = force/mass which is proportional to 1/distance^2. Using the parallelivity, you get falloff, but it's not the same as inverse squared. Any insights as to how maybe there is still a relationship between the two?

My code is:

double parallelity = 0;
size_t count = 0;

// vectors are normalized
for (size_t i = 0; i < vectors.size(); i++)
{
	for (size_t j = 0; j < vectors.size(); j++)
	{
		//if (i == j)
		//	continue;

		const double d = vectors[i].dot(vectors[j]);

		parallelity += d;
		count++;
	}
}

parallelity /= count;

parallelity = abs(parallelity);

taby said:
for (size_t i = 0; i < vectors.size(); i++) {

for (size_t j = 0; j < vectors.size(); j++) {

You did it again! /:O\
You know what that means… living under the bridge… remember?

So, before helping out on imaginary gravitons, which ofc. i can, i want you to optimize this loop!

Advertisement

Like this?

for (size_t i = 0; i < vectors.size(); i++)
{
	for (size_t j = (i + 1); j < vectors.size(); j++)
	{
	...
	}
}	

This way the time complexity is like O(n * (n - 1) / 2) instead of O(n * n). It's better than no optimization, thank you for pointing that out, sir.

… and we can always pretend that we're talking about Coulomb's electromagnetism instead of gravitation. When using Newton's gravitation, they're pretty much the same thing, with the exception of their strengths.

for (size_t i = 0; i < vectors.size() - 1; i++)
{
	for (size_t j = (i + 1); j < vectors.size(); j++)
	{

Subtracted one just to nitpick. Every cycle counts. : )

taby said:
… and we can always pretend that we're talking about Coulomb's electromagnetism instead of gravitation. When using Newton's gravitation, they're pretty much the same thing, with the exception of their strengths.

But magnets can both attract and repel, so how can this be the same as gravity?

But never mind. I was wondering if you surely deal with a vector field, where the dot products can be negative.
Maybe you want a field of lines instead, so dot products are always positive? I mean, mostly we measure if lines are parallel, not so much for vectors.

Here is the whole code:

https://github.com/sjhalayka/sphere_collider​

In particular, here is the parallelivity code:

https://github.com/sjhalayka/sphere_collider/blob/e6b5db8abc64b2a5a6192232bd980f1a9184acec/main.cpp#L69

Advertisement

Do you understand where I'm coming from though? If the “force lines” are practically parallel, then there is no attraction, like with the inverse falloff, but not the same.

taby said:
Do you understand where I'm coming from though?

Nah. Relativistic physics of objects with teleparallel gravity?

taby said:
If the “force lines” are practically parallel, then there is no attraction

Meaning if we have a distant cube shaped star, but it is so far away the lines from its vertices to us become parallel, it's gravity does not affect us? Something like that?

Maybe i can indeed help. Because i use a similar concept for GI, and thus there is no need for a inverse distance falloff. It's called 'solid angle' (angle of a cone with the tip at the receiver, bounding a distant sphere object). It's used to calculate a ‘form factor’, which tells how much radiation of the object we receive. If the object is infinitely far away, solid angle and form factor become zero.
This concept is ignored in path tracing, which tries to approximate a solution with many point samples. Objects with larger area get more samples so statistical correctness is given.
But it is used in other methods which do area integration, e.g. the Radiosity Method.
It also was used for temperature and electromagnetic fields stuff iirc.

JoeJ said:

Nah. Relativistic physics of objects with teleparallel gravity?

Nope, just Newtonian gravitation.

Meaning if we have a distant cube shaped star, but it is so far away the lines from its vertices to us become parallel, it's gravity does not affect us? Something like that?

Maybe i can indeed help. Because i use a similar concept for GI, and thus there is no need for a inverse distance falloff. It's called 'solid angle' (angle of a cone with the tip at the receiver, bounding a distant sphere object). It's used to calculate a ‘form factor’, which tells how much radiation of the object we receive. If the object is infinitely far away, solid angle and form factor become zero.
This concept is ignored in path tracing, which tries to approximate a solution with many point samples. Objects with larger area get more samples so statistical correctness is given.
But it is used in other methods which do area integration, e.g. the Radiosity Method.
It also was used for temperature and electromagnetic fields stuff iirc.

Right. So it's basically the shape. In my case that cross-section of a sphere is a circle. Star shaped is not hard if you have the area of the shape. The solid angle is pretty much the same as the inverse square falloff?

taby said:
In my case that cross-section of a sphere is a circle.

For radiosity this is what matters, because we integrate surface area.
But for gravity it should not work, because you want to integrate mass properties, so a volume.
That's surely much harder. So i wonder about your motivation. For Newtons physics you can just work with total mass and the center of that mass. And even if you drill a hole into a planet to go to it's center where gravity is zero, you can still always use the COM and only have to figure out a model decreasing the effective gravitational mass.

taby said:
The solid angle is pretty much the same as the inverse square falloff?

Yes, but to calculate it, you again need squared distance. It's the same math regarding distance, we can ignore it only after that point.
Unlike distance, solid angle involves area. If the object is a sphere, it's simple trig to calculate the solid angle, and a circle area from that, as you say.
But mostly there is another term required to give the emitted energy its weight.
For lighting that's the cosine law.

Here we have a patch instead a sphere. The lines from the origin to its vertices describe the solid angle of the patch projected to the unit sphere. The area of the projected patch does not change if we rotate the patch around the origin.
But that's not what we need. Due to the cosine law, light coming from the top (along the surface normal) contributes more than lighting coming from the side. Thus the down projection to the surface plane. If we rotate the patch to the side, the area of this projection becomes less, so using this as the weighting factor of the patch radiation gives correct radiosity results. That's the form factor.

However, even for simple shapes there exist no analytical solutions. For my disc shaped surfels i use an approximation for the form factor, like everybody does.
For higher accuracy, i would not only need to generate a finite elements representation of the scene, i would also need to create a second finite elements representation of each surfel while integrating it. That's not practical ofc.

And you would need to do the same i think. You would need to divide objects into volumetric finite elements, eg. voxels. Only then you could weight them correctly by their mass to calculate gravity. For example, you can't work with only surface vertices, checking how parallel their difference to the receiver is, calculating the average and use that for a weight. Vertices don't describe the mass properties of the interior below the surface. Thus i wonder: What do you try to do, making such effort on calculating gravity more accurately might be worth it?

This topic is closed to new replies.

Advertisement