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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by designico · Nov 18, 2013 at 05:48 PM · mathmathf

A math issue.

Hey Guys,

I need to calculate a special value. It goes like that: If "velocityX" == 0.1 than the variable "smoothTime" should be == 0.01. And if "velocityX" == 4.0 than the variable "smoothTime" should be == 0.001. The "velocityX" is a dynamic value and the "smoothTime" should have a relation to it but within a special range. It's a shame but I've no Idea how to calculate relation, do you?

Comment
Add comment · Show 1
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 Dracorat · Nov 18, 2013 at 05:56 PM 0
Share

Is this a linear progression?

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Wiki

Answer by designico · Nov 21, 2013 at 05:56 PM

Hey guys thanks for your help...

I guess you was right, it was the lineare funktion: y = mx + f. Because of having a issue with understanding your answers I watched some back in the days school math tutorials. It helped me to build my script out of this:

 m = (y2-y2)/(x2-x1)  --> (y point two - y point one) / (x point two - x point one)
 t = y - m*x
 x = ( y - t )/m  
 x = smoothTime 
 y = finalVelocityX

I calculated m & t with the help of a calculater.

 float smoothTime = (finalVelocityX) - 2.222f)/(-22.222f);

(now the value is differnet from my first posting(!))

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 Dracorat · Nov 18, 2013 at 05:58 PM

Assuming it's linear progression:

 if(velocityX < 0.1f || velocityX > 4.0f) throw new ArgumentException("velocityX out of range.");
 percentAlong = 1f - ((4.0f - velocityX) / (4.0f - 0.1f));
 smoothTime = (0.01f - 0.001f) * percentAlong + 0.01f;
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 smallbit · Nov 18, 2013 at 06:13 PM

If you have more sample data you can use linear regression to find the equation for that in for instance excel, feed data to cells insert lineal chart, than click on the line -> format tread-line and mark option "display equation". lets say X is velocity Y is smoothTime and you will endup with somthing Y = Ax + c or something to calculate smoothTime basing on velocity.

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

19 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

Related Questions

How I can increase num 1 to num 2 in x time? 1 Answer

Rotate Center Pivot based Object like a Draw Bridge 2 Answers

Math.Abs slows down on time.timescale 0 Answers

Why is there no Mathf.Truncate? 2 Answers

[Math] Why is this possible ? 1 Answer


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