Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 zardini123 · Jul 22, 2015 at 04:23 PM · algorithmproblema

Get the point between 2 other points using weights

Hello. I have another algorithm issue.

I have 2 weights.

Weight 1 (W1) is between 0 and 1.

Weight 2 (W2) is the "opposite" of W1. W2 = Mathf.Abs(W1 - 1.0f)

I have 2 points.

When W1 is 1.0 the final point is Point 1.

When W2 is 1.0 the final point is Point 2.

When W1 and W2 is 0.5 the final point is the midpoint of Point 1 and Point 2.

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
0
Best Answer

Answer by alexi123454 · Jul 22, 2015 at 05:01 PM

How many dimensions is your point? If it's 2 dimensional, you can use Vector2.Lerp(Point1, Point2, W2). For 3 dimensional points, you can use the same function with Vector3.

If you don't want to use the built in functions, the mathematics behind it are as such:

 vectorBetweenPoints = Point2 - Point1;
 
 finalValue = Point1 + (vectorBetweenPoints * W2);
Comment
Add comment · Show 4 · 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 zardini123 · Jul 22, 2015 at 05:03 PM 0
Share

Oh yes. Thank you that is perfect. (By the way I am using Vector3).

avatar image zardini123 · Jul 22, 2015 at 05:07 PM 0
Share

Wait so I use W2 ins$$anonymous$$d of W1?

avatar image alexi123454 · Jul 22, 2015 at 05:18 PM 0
Share

That's correct. Since you're saying that W2 being at 1.0 should be the second point, you should use W2 in the math.

You could use W1 ins$$anonymous$$d, if you switch things around so that Point2 is the first value, and Point1 as the second value.

avatar image zardini123 · Jul 22, 2015 at 05:21 PM 0
Share

Okay. Thank you!

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

22 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

Related Questions

Algorithm Help 3 Answers

Generating Triangles Given a Set of Points 1 Answer

A* Algorithm help? 0 Answers

Perlin Noise for 3d Voxel Terrain 1 Answer

Need an Algorithm to solve the Geometric Puzzle 2 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