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

  • SEARCH
  • Home
  • 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 9035629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:48:09+00:00 2026-06-16T08:48:09+00:00

I have a sphere in my program and I intend to draw some rectangles

  • 0

I have a sphere in my program and I intend to draw some rectangles over at a distance x from the centre of this sphere. The figure looks something below:

enter image description here

The rectangles are drawn at (x,y,z) points that I have already have in a vector of 3d points.
Let’s say the distance x from centre is 10. Notice the orientation of these rectangles and these are tangential to an imaginary sphere of radius 10 (perpendicular to an imaginary line from the centre of sphere to the centre of rectangle)

Currently, I do something like the following:

For n points vector<vec3f> pointsInSpace where the rectnagles have to be plotted

for(int i=0;i<pointsInSpace.size();++i){
    //draw rectnagle at (x,y,z)
}

which does not have this kind of tangential orientation that I am looking for.
It looked to me of applying roll,pitch,yaw rotations for each of these rectangles and using quaternions somehow to make them tangential as to what I am looking for.
However, it looked a bit complex to me and I wanted to ask about some better method to do this.

Also, the rectangle in future might change to some other shape, so a kind of generic solution would be appreciated.

  • 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-16T08:48:11+00:00Added an answer on June 16, 2026 at 8:48 am

    I think you essentially want the same transformation as would be accomplished with a LookAt() function (you want the rectangle to ‘look at’ the sphere, along a vector from the rectangle’s center, to the sphere’s origin).

    If your rectangle is formed of the points:

    (-1, -1, 0)
    (-1,  1, 0)
    ( 1, -1, 0)
    ( 1,  1, 0)
    

    Then the rectangle’s normal will be pointing along Z. This axis needs to be oriented towards the sphere.

    So the normalised vector from your point to the center of the sphere is the Z-axis.

    Then you need to define a distinct ‘up’ vector – (0,1,0) is typical, but you will need to choose a different one in cases where the Z-axis is pointing in the same direction.

    The cross of the ‘up’ and ‘z’ axes gives the x axis, and then the cross of the ‘x’ and ‘z’ axes gives the ‘y’ axis.

    These three axes (x,y,z) directly form a rotation matrix.

    This resulting transformation matrix will orient the rectangle appropriately. Either use GL’s fixed function pipeline (yuk), in which case you can just use gluLookAt(), or build and use the matrix above in whatever fashion is appropriate in your own code.

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

Sidebar

Related Questions

I have web service deployed in Web Sphere and this service is SSL enabled.
I have a base class called Geometry from which there exists a subclass Sphere
I have write some code but my program is too slow. The problem is
I have a frame and I want to show some white sphere in the
I've built this piece of code...(javascript) Now we have a red sphere on the
I have a very simple openGL program in C++. I have made a Sphere
How we can draw a sphere on canvas in Android? Canvas does not have
I have defined 2 points on the surface of a sphere using spherical coordinates.
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=

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.