Advertisement

Falloff

Started by October 17, 2024 09:17 PM
76 comments, last by taby 1 week, 1 day ago

I have a code to calculate inverse square falloff, but it's not working as I had hoped. Any big ideas? For instance, where dimension == 3, the falloff should be proportional to 1/r^2.

vector_3 get_random_point_in_ellipse(double radius_a, double radius_b)
{
	double rho = static_cast<double>(rand() % RAND_MAX) / static_cast<double>(RAND_MAX);
	double phi = 2.0 * pi * static_cast<double>(rand() % RAND_MAX) / static_cast<double>(RAND_MAX);

	vector_3 point;
	point.x = sqrt(rho) * cos(phi);
	point.y = sqrt(rho) * sin(phi);
	point.x = point.x * radius_a;
	point.y = point.y * radius_b;

	return point;
}

double get_antiparallelity_from_unnormalized_vectors(vector<vector_3> vectors)
{
	double antiparallelity = 0;
	size_t count = 0;

	for (size_t i = 0; i < vectors.size(); i++)
		vectors[i].normalize();

	for (size_t i = 0; i < vectors.size() - 1; i++)
	{
		for (size_t j = (i + 1); j < vectors.size(); j++)
		{
			// antiparallelity
			const double d = 1.0 - abs(vectors[i].dot(vectors[j]));

			antiparallelity += d;
			count++;
		}
	}

	//cout << count << " " << vectors.size() * (vectors.size() - 1) / 2.0 << endl;

	antiparallelity /= count;

	return antiparallelity;
}

double antiparallelity_from_ellipse(const double x_radius, const double emitter_distance, const double dimension)
{
	ellipse_points.clear();

	for (size_t i = 0; i < n; i++)
	{
		const double dimension_diff = 1.0 - (3.0 - dimension);
		double x_radius = 1.0;

		ellipse_points.push_back(get_random_point_in_ellipse(x_radius, dimension_diff * x_radius));
	}

	for (size_t i = 0; i < ellipse_points.size(); i++)
		ellipse_points[i].z = -emitter_distance;

	return get_antiparallelity_from_unnormalized_vectors(ellipse_points);
}

int main(int argc, char** argv)
{
	cout << setprecision(20) << endl;
	srand(static_cast<unsigned int>(time(0)));

	double dimension = 2.0; // between 2 and 3

	for (double i = 1; i < 1e10; i += 1e2)
	{
		const double exponent = dimension - 1.0;

		cout << i << " " << antiparallelity_from_ellipse(1.0, i, dimension) / pow(i, exponent) << endl;
	}
	
	...
	
	return 0;
}

Or am I over complicating things? Should I just be using the area of the receiver?

Advertisement

taby said:
Should I just be using the area of the receiver?

Idk what you try to do, but if it's about radiation, it would be the area of the emitter which matters. Something that has no area (or volume) can not cause any radiation.
You can look up the concept of a ‘form factor’, which has a simple formula for disc shaped emitters (surfels) often used in graphics:

https://developer.nvidia.com/gpugems/gpugems2/part-ii-shading-lighting-and-shadows/chapter-14-dynamic-ambient-occlusion-and

https://developer.nvidia.com/gpugems/gpugems2/part-v-image-oriented-computing/chapter-39-global-illumination-using-progressive

Afaik, the same concept is also used for heat transfer or electro magnetism.
But keep in mind the given formula is an approximation ignoring how perspsectiv projection affects the visible area from the receiver. The error becomes noticeable if emitter and recivers are close to each other or area is very large.

taby said:
double get_antiparallelity_from_unnormalized_vectors(vector vectors)

I have doubts in this function. Maybe ther is something better. Using covarianve matrix and singular value decomposition, you could caculate this from a given (weighted) point distribution:

Basically it gives you the orientation and size of an ellipsoid fitting the distribution of the points.
So it coudl tell you how flat a galaxy is for example.
I could post some code.

I'm not sure what I'm needing in the first place, to be honest. So, thank you for your response. As always, it's informative.

I know one thing: A 2-sphere is a 3-D emitter surface, and a 1-sphere (a circle) is a 2-D emitter, and the dimension in between is given by the sphere volume divided by the volume of the ellipsoid, e.g. D = 3 - (V_s / V_e). As dimension reduces, gravitation increases in strength and the falloff reduces from r^2 to r^1.

P.S. Right now I am simply finding a pseudorandom point in the ellipse, then trace that ray back to the origin. This way I don't have to worry about casting rays that don't hit the ellipse.

P.P.S. This is the analytical code below. What I'm trying to do is model it numerically.


#include <iostream>
using namespace std;

int main(void)
{
	const double c = 299792458; // Speed of light in vacuum
	const double G = 6.674e-11; // Gravitational constant
	const double M = 1e41; // Galactic bulge mass

	const double start_distance = 6.1495e19; // Galactic bulge radius
	const double end_distance = start_distance*c*c;// 1e21; // just past the solar radius

	double v = sqrt(G * M / start_distance); // Speed with dark matter

	const size_t resolution = 1000;	

	const double step_size = (end_distance - start_distance) / (resolution - 1);

	for (double r = start_distance; r <= end_distance; r += step_size)
	{
		const double v_N = sqrt(G * M / r); // Speed without dark matter

		if (v < v_N)
			v = v_N;

		const double D = 3.0 - log(v / v_N) / log(c);

		const double G_a = v * v * r / M;

		cout << r << " " << G_a << endl;

//		cout << r << " " << D << endl;

	}

	return 0;
}

Notice that the G_a constant runs with increasing distance. Basically, at bulge_radius * c metres, the G_a constant is G*c. And at bulge_radius * c * c, the G_a constant is G*c*c. So on and so forth.

Advertisement

OK, please take a look at this diagram:

Oblate ellipsoid A with normals at collision position.

Prolate ellipsoid B with normals at collision position.

Prolate ellipsoid B with normals from ellipsoid B. This is ultimately what I want, in terms of an emitter.

taby said:
OK, please take a look at this diagram:

I don't understand at all. ; )

But i wonder, with your model of anisotropic gravity, if we would totally flatten the ellipsoid at the bottom, would gravity only ‘radiate’ to the left an right, so there is no attraction upwards and downwards?

If this would be true, wouldn't we have measured this effect in the real world already?
I mean, our planet is a bit flattened, our solar system is flat, our galaxy is flat, and all have the same axis afaik. So we would have noticed this from measurements, and it might already affect space ship trajectories?

You understand completely correctly. Yes, a totally flattened disk would radiate only along a plane. The thing is, the lower bound of the dimension is D = 2.98, with regard to the gravitational field in our Galaxy at our orbit distance. So, it would be very hard to notice the difference between it and D = 3.0 (other than a flat rotation curve).

taby said:
The thing is, the lower bound of the dimension is D = 2.98, with regard to the gravitational field in our Galaxy at our orbit distance. So, it would be very hard to notice the difference between it and D = 3.0

They can already detect gravitational waves, so i'm optimistic they can notice that too.
You only need to convince them to look for it.

If you succeed, flat earthers shall be replaced with flat gravitators, and a new science unites them all. \:D/

Advertisement