Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8020457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:41:54+00:00 2026-06-04T21:41:54+00:00

How do you convert between Cartesian and Polar (and back) coordinate systems in 3D

  • 0

How do you convert between Cartesian and Polar (and back) coordinate systems in 3D space? Preferably with a c# example but anything would really be appreciated. Thanks!

Edit
When 20% of the change is taken into account (not forming a sphere)

enter image description here

Edit 2

private void Spherise() {
        for (int i = 0; i < vertices.Count; i++) {
            float radius = this.radius;
            float longitude = 0;
            float latitude = 0;

            float sphereRadius = 32;

            Color color = vertices[i].Color;

            ToPolar(vertices[i].Position - centre, out radius, out longitude, out latitude);
            Vector3 position = ToCartesian(sphereRadius, longitude, latitude) + centre;

            Vector3 normal = vertices[i].Position - centre;
            normal.Normalize();

            const float lerpAmount = 0.6f;
            Vector3 lerp = (position - vertices[i].Position) * lerpAmount + vertices[i].Position;
            vertices[i] = new VertexPositionColorNormal(lerp, color, normal);
        }
    }

    private void ToPolar(Vector3 cart, out float radius, out float longitude, out float latitude) {
        radius = (float)Math.Sqrt((double)(cart.X * cart.X + cart.Y * cart.Y + cart.Z * cart.Z));
        longitude = (float)Math.Acos(cart.X / Math.Sqrt(cart.X * cart.X + cart.Y * cart.Y)) * (cart.Y < 0 ? -1 : 1);
        latitude = (float)Math.Acos(cart.Z / radius) * (cart.Z < 0 ? -1 : 1);
    }

    private Vector3 ToCartesian(float radius, float longitude, float latitude) {
        float x = radius * (float)(Math.Sin(latitude) * Math.Cos(longitude));
        float y = radius * (float)(Math.Sin(latitude) * Math.Sin(longitude));
        float z = radius * (float)Math.Cos(latitude);

        return new Vector3(x, y, z);
    }

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:41:56+00:00Added an answer on June 4, 2026 at 9:41 pm

    From Cartesian to Polar:

    r = sqrt(x * x + y * y + z * z)
    long = acos(x / sqrt(x * x + y * y)) * (y < 0 ? -1 : 1)
    lat = acos(z / r)
    

    From Polar to Cartesian:

    x = r * sin(lat) * cos(long)
    y = r * sin(lat) * sin(long)
    z = r * cos(lat)
    

    I haven’t tested it yet.

    You can rewrite to reduce number of floating point operations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there some way to convert between F# List and F# Tuple? For example:
I would like to be able to convert between std::vector and its underlying C
I need to convert between these two classes, and want to maintain DRY but
I want many ways to convert between the two on both systems. I am
I want to convert between various integral types; for example Word32 and Word8. What
I would like to automatically convert between tabs and spaces for indentation when I
When I try to convert between date and string in Flash CS4, I use
I want to be able to convert between the Gregorian and Julian calendars (note:
I am looking for an algorithm to convert between HSL color to RGB. It
I have written some general functions to convert between decimal and any other base-n

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.