#Milky way Orion arm

8 messages · Page 1 of 1 (latest)

deep sapphire
#

Hi I am trying to make a milky way Orion arm thing.
From my reading it requires a 12 degree logarithmic spiral.

I have tried tweaking the numbers and using perplexity AI, however I just cannot get the distribution right. I want to have it more even distribution, preferably without that core in the middle either.

I will refine later to have stars on the sides but right now the spiral is most important.

For context the "stars"
are about 10m radius,

Also the comments about the maths start is from AI not me.
And the spiral is too wide

#

what I am vaguely trying to reproduce

balmy fractal
#

for a more even sampling along the spiral path, I would recommend incrementing the t variable by dist / r each iteration instead of calculating it from an index.

#

and dist is a parameter you can choose that controls the distance between points along the path

deep sapphire
# balmy fractal for a more even sampling along the spiral path, I would recommend incrementing t...

Thanks I couldn't understand your exact instructions but, I did work something out based on it. reason I was confused is that t is based on r and had a kind of circular dependency so incrementing that value would break things, I added length and dist idea is length was count and `dist was parameter

fn setup_galaxy_view(
    mut commands: Commands,
    star_query: Query<(&StellarSystemID, &DisplayName), With<Star>>,
    asset_server: Res<AssetServer>,
) {
    //snip

    let a = 1.01; // Controls the distance between spiral arms
    let b = 12.0f32.to_radians(); // Controls how tightly the spiral is wound
    info!("galaxy start {}", star_query.iter().count());

    let mut length = 30.0;
    let dist = 5.0;
    let star_gltf = asset_server.load(GltfAssetLabel::Scene(0).from_asset("galaxy/GStar.glb"));
    for (i, (solar_id, name)) in star_query.iter().enumerate() {
        trace!("galaxies");
        let i = 1.0 + i as f32;

        let t = i as f32 * 0.382;
        let r = a * (b * t).exp();

        length += t / dist;

        let x = length * t.cos();
        let z = length * t.sin();

        // let x = x.sqrt();
        // let z = z.sqrt();

        trace!(?x, ?z, ?r, ?t, ?a, ?b);

        commands
            .spawn((
                SceneBundle {
                    scene: star_gltf.clone(),
                    visibility: Visibility::Hidden,
                    transform: Transform::from_xyz(x, 0.0, z),
                    ..Default::default()
                },
                On::<Pointer<Down>>::send_event::<StellaMove>(),
                *solar_id,
                GalaticViewStar,
            ))
            //snip
    }
}```
#

I am going to work on this further before I mark as resolved

balmy fractal
#

yeah the circular dependency is kind of inherent to the problem, but in your case it shouldn't matter that much, you can get away in just re-using the previous r value.
So, to break it down, based on your initial post:

  • you can get rid of the i variable
  • make r and t be a mutable variables scoped outside of the loop, for examplelet mut t = 1.0 and let mut r = a * (b * t).exp();
  • make dist a constant parameter that doesn't change during iteration, you can tweak it's value to have the stars more spaced out
  • in each iteration, you then increment t += dist / r
  • in each iteration, update r like you did initially, r = a * (b * t).exp();

This should just work, because the t iteration will then just use the result for r from the previous iteration. This is not numerically exact, but close enough for your purposes. The stars will have a roughly constant spacing.

#

the spiral will start at different radii depending on what value you chose for the initial t