Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by urliam · Jun 27, 2013 at 10:40 AM · c#physicsvelocityrotatearoundorbit

Translating Speed into rotation degress\sec

Hi all!

If I understand correctly, then transform.rotatearound uses three variables. The first is a transform to orbit, the second is the direction of the rotation and the thid (which is what I wish to discuss) is the speed of the rotation calculated via degrees per second (or whatever timeframe you choose).

What I wish to ask is - Say that an object moves in a certain speed and is then oredered to orbit another object via the RotateAround command. How to I assign it a correct degrees per sec value that will maintain it's current speed perfectly and (if needed) translate it back into speed should I wish it to lose its' orbit?

I know it has something to do with the distance between them but my brain just can't figure out the physics...

Lastly, and on a related note - the Direction. How do I make sure that, given the velocity vector of an object A and it's relation in space to object B, said object A enters orbit in a direction that fits its' inital velocity. I managed to figure out a very VERY rough system with many "if" clauses to figure out all possible cases for this but I was wondering if maybe there is a more elegant approach :)

much obliged!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by moonstruck · Jun 27, 2013 at 01:57 PM

The linear velocity v = w R, where w is the angular velocity and R is the radius, thus w = v / R. Converting this from radians we have the formula for the velocity (degrees per second): w = 180 v / ( pi * R ).

The rotation axis is [ v, ( B - A ) ], where B - A is the vector from the center of rotation to your object (they should not be collinear in order to get a non-zero axis). So you can rotate around Vector3.Cross( v, B-A ).normalized. If it goes in the wrong direction then change the sign of the vector. :)

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image urliam · Jun 27, 2013 at 02:17 PM 0
Share

I see... and how should I calculate v and R? vector3.magnitude on both (using the rigidbody.velocity for v and the difference between the positiong of the orbiting object and the gravity center for R)?

the formula turns out something entreiyl different from what I came up with so thank whatever diety is appropriate you came along, sir! :D

regarding the rotation axis, should I again use vector3.magnitude to calculate (B-A)? or is there a more fitting function?

many thanks!

avatar image moonstruck · Jun 27, 2013 at 02:32 PM 1
Share

You are welcome. :D

Yeah just use rigidbody.velocity as v (it is in meters per second). Don't normalize R because you need the original radius (not unit length) to get proper result.

Also there is no need to normalize B - A for the axis because you normalize the final cross product.

avatar image urliam · Jun 27, 2013 at 02:38 PM 0
Share

so which functions SHOULD I use to get R?

I think i'll just go out and ask for it bluntly - could you write a sample code of how this should all end up looking lik? because when I use 180*rigidbody.velocity*mathf.pi/vector3(A-B) it makes visual studio kinda go wwwwWWWHHHHHHAAAAT?

avatar image moonstruck · Jun 27, 2013 at 02:47 PM 1
Share
 public Transform obj;
 public Transform center;
 ...
 Vector3 R = center.position - obj.position;
 Vector3 v = rigidbody.velocity;
 float w = 180 * v.magnitude / ( $$anonymous$$athf.PI * R.magnitude );
 
 Vector3 axis = Vector3.Cross( v, R ).normalized;

Something like this. :)

avatar image urliam · Jun 27, 2013 at 03:05 PM 0
Share

it's... beautifull!

I salute you sir!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Using Lerp in a Constant Moving Object 1 Answer

Orbit Sim without Physics Engine 1 Answer

Reducing rounding errors in my physics solvers 0 Answers

Distribute terrain in zones 3 Answers

Fps Movement Velocity Decrease 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges