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
0
Question by Feref2 · Sep 19, 2020 at 07:58 PM · normalsvectorslinearequation

How to get the right equation of and edge normal in motion?

So I have an object that´s being squeezed, changing its localScale in x from 1 to 2 and in y from 1 to 0.5. To achieve this in a realistic way in which movement between frames simmulates this constant area, each vertex moves in a curve to its final position. alt text

Normally, the edge is constant and getting its equation is as simple as getting the cross product of (nextVertex - currentVertex) and the face´s normal. However, because the edge is inclined, its rotation changes along its path. I can´t upload the image, but is the case from above. The edge vector is from the bottom vertex to the top, always aligned at the x axis in this case (though that´s probably going to change), has also a constant depth axis and basically the only thing that changes is the height at both points, which is shown in the image. The edge changes because the top vertex has more depth than the bottom one (even if from this perspective looks like a perfect cube).

So the equation I thought would work was this: startEdgeNormal + (endEdgeNormal - startEdgeNormal) * t; //Which is a lineal transition from start to end where "t" is the frame´s time, that goes from 0 to 1.

But it doesn´t work. I know this because I compared it with a fixed normal that I knew was right at t = 0.5f; However, because am going to use this equation to solve for other variables, I don´t know yet the value of t and therefore I can´t use that method.

When I compared both results, they were similar, but different enough to be considered != by an if statement. I know that comparing equal floats might not work because of their lack of precision; but when we are comparing vectors instead c# still considers very similar vectors equal.

So, is there a better way of getting the edge normal´s equation at time t?

I tried normalizing all vectors first and now even without doing that. Either way they differ.

captura-de-pantalla-88.png (361.0 kB)
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 Feref2 · Sep 19, 2020 at 10:32 PM

So... I actually found out on my own. See, I was normalizing the edge vectors (not the normals, just the vectors). I did that because I only wanted the check for the rotation without considering the magnitude, but that apparently changes direction. The solution is as simple as never normalizing the edge vectors, then get the cross product.

Comment
Add comment · Show 2 · 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 Feref2 · Sep 19, 2020 at 10:37 PM 0
Share

And, I forgot to mention, also using th t variable of the opposite axis, because in this case only y changes and the right equation that I used checked the normal based on x.

avatar image Bunny83 Feref2 · Sep 19, 2020 at 11:21 PM 0
Share

From your question it's completely unclear what kind of curve you're using. The normal completely depends on that fact. A linear interpolation would only work if you used a quadratic bezier curve. The way you usually calculate the normal is to first obtain the tangent at t. The tangent equation for a bezier curve is simply the first derivative of the curve equation you're using. So if you use a quadratic bezier curve the tangent curve is linear. If you use a cubic bezier, the tangent equation will be quadratic.

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

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

How can I get back a hit? 1 Answer

Looking for a way to solve a 4th degree polynomial equation with constraints at runtime 1 Answer

How to detect terrain's mesh normals at given point? 0 Answers

Orienting character to walls and ceiling 3 Answers

How do I manually calculate Normals for my Meshes? 4 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