Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by kramazeek · Mar 19, 2019 at 09:59 AM · mathsine

Sine Wave Without the SIne Function?

Hi there, Is there a formula for the rate of acceleration/decay of a sine wave? Namely, if you set up a cube, place it at 0,0,0 and then applied the return value from the Sine function (incrementing 0 deg - 90 deg values as the angle argument * a 1 unit radius) to the cube's x position it would move back and forth from -1 to 1 decelerating exponentially before it reached both -1 and 1. Is there a formula that could be used to calculate and express the exponential decay in speed as a negative force instead of using the Sine function?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by elenzil · Mar 19, 2019 at 06:29 PM

a dynamic simulation of a spring will produce the spring's displacement as a sine function of time. the basic formula there is the restorative force is negatively proportional to the spring displacement. then you integrate that w/r/t time however you like.

here's a spreadsheet showing that, with basic euler integration.

Comment
Add comment · 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
0

Answer by kramazeek · Mar 20, 2019 at 04:50 AM

Thank you, elenzil. I believe that may be what I'm after but I'll have to play around and see. Much appreciated!

Comment
Add comment · 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
0

Answer by timoffex · Mar 22, 2019 at 07:43 PM

If I understand the question, you are asking whether you can create sinusoidal movement using forces. The answer is yes. You still have to use the sine function because if an object's position at any time t is sin(t), then its acceleration is -sin(t).

Here are two pieces of code that will produce very similar motion (assuming no friction, no other forces, no obstacles):

 // Movement by changing transform.position.
 void FixedUpdate()
 {
     float t = Time.time;
     transform.position = Mathf.Sin(t) * Vector3.right;
 }

 // Movement by applying a force.
 Rigidbody rigidBody;
 void FixedUpdate()
 {
     float t = Time.time;
     float acceleration = -Mathf.Sin(t); // second derivative of position
     float force = acceleration * rigidBody.mass; // force = mass * acceleration
     rigidBody.AddForce(force * Vector3.right);
 }



Acceleration is defined to be the second time derivative of position. Using this requires some basic calculus, but it will allow you to write any motion in terms of forces just by following the two definitions:

 1. Acceleration is the second time derivative of position (can be written symbolically "a(t) = (d/dt)^2 x(t)").
 2. Force is mass times acceleration (a.k.a. "F = ma").
Comment
Add comment · 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

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

109 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 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 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 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 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 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 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

Top down wasd movement dependent on rotation of the character - Mathematical problem!!! 2 Answers

Trying to obtain sine/cosine by angles giving me imprecise values 1 Answer

I can't find cossine. 1 Answer

Math - Changing the frequency of a sine wave in real-time 1 Answer

Looking at a target in 2D 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