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 NMS_TomiBary · Oct 01, 2017 at 12:55 PM · vector3axis

How to get axially symmetric vector3?

Hello,

i have simple question. I have some two Vectors3 ( first is pattern, second is axis) and need to get Vector3, which is axially symmetric.

We did it on high school, but i forgot it. (I only know that i had to calc normal vector from point (pattern vector) to axis and calculate distance to it and then make it "inverse") Everything was in 2D

But i am here to ask you, if is here the easier way, how to get vector in 3D.

Example: alt text

vectors.png (11.8 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

3 Replies

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

Answer by Bunny83 · Oct 01, 2017 at 01:57 PM

You can simply use Vector3.ProjectOnPlane to get a vector that represents the displacement orthogonally from "u" to v. Just subtract this vector two times from "v" and you get "w"

 Vector2 a = Vector3.ProjectOnPlane(v, u);
 Vector2 w = v - 2*a;


If you want to know the raw math behind this, that's what ProjectOnPlane does:

 public static Vector3 ProjectOnPlane(Vector3 vector, Vector3 planeNormal)
 {
     return vector - Vector3.Project(vector, planeNormal);
 }

and that's what Project does:

 public static Vector3 Project(Vector3 vector, Vector3 onNormal)
 {
     float num = Vector3.Dot(onNormal, onNormal);
     if (num < Mathf.Epsilon)
         return Vector3.zero;
     return onNormal * Vector3.Dot(vector, onNormal) / num;
 }

and Vector3.Dot is just the dot product:

 public static float Dot(Vector3 lhs, Vector3 rhs)
 {
     return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z;
 }

If you have further questions how it actually works, just add a comment.

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 ImpOfThePerverse · Oct 01, 2017 at 04:47 PM

Another way would be to use Quaternion.FromToRotation:

 Quaternion halfRotation = Quaternion.FromToRotation(startVector, midpointVector);
 Vector3 resultVector = halfRotation * midpointVector;

edit: Or, I guess you're looking to rotate pattern, so the code would look like:

 Quaternion halfRotation = Quaternion.FromToRotation(pattern, axis);
 Vector3 resultVector = hafRotation * halfRotation * pattern;


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 NMS_TomiBary · Oct 01, 2017 at 05:45 PM

Thank you both. While i was reading Vector3.ProjectOnPlane i found that Unity has function called Vector3.Reflect. And it solved my problem.

Again thank you very much.

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

87 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

Related Questions

I need help with moving an object on only the Y axis with mouse input 1 Answer

Get angle around a specified axis. 1 Answer

Problem with lerping Y axis 0 Answers

Use yAxis as a Vector3(0,0,yAxis) paramenter? 3 Answers

three second timer. 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