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 question was closed Nov 01, 2021 at 08:42 PM by $$anonymous$$ for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by $$anonymous$$ · Nov 01, 2021 at 12:14 PM · mathvectorsrotations

Rotate and proportionally scale a vector

Hello, how to rotate a vector and scale its magnitude proportional to the angle to get a for example constant value on the y-axis? vectors

1.png (4.4 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

  • Sort: 
avatar image
1
Best Answer

Answer by andrew-lukasik · Nov 01, 2021 at 06:12 PM

A pani od matematyki nie uczyła jak liczyć miejsce zerowe funkcji, hm?


miejsce zerowe funkcji unity

 using UnityEngine;
 public class MiejsceZeroweFunkcjiLiniowej : MonoBehaviour
 {
     [SerializeField] Vector2 _In = Vector2.one;
     [SerializeField] float _InRotation = 0;// degrees
     [SerializeField] Vector2 _Out;
     [SerializeField] float _yCutoff = 1.5f;
     void OnValidate ()
     {
         float inVecAngle = Mathf.Atan2( _In.y , _In.x );// radians
         float inVecAngleRotated = inVecAngle + Mathf.Deg2Rad*_InRotation;// radians
         Vector2 inVecRotated = new Vector2{ x=Mathf.Cos(inVecAngleRotated) , y=Mathf.Sin(inVecAngleRotated) };// unit vector, for simplicity
         float fx = inVecRotated.y / inVecRotated.x;// f(x) = (vec.y/vec.x)*x + 0
         float fy = inVecRotated.x / inVecRotated.y;// f(y) = (vec.x/vec.y)*y + 0
         _Out = new Vector2{ x=fy*_yCutoff , y=_yCutoff };
     }
     void OnDrawGizmos ()
     {
         Gizmos.color = Color.yellow; Gizmos.DrawLine( new Vector3{x=-10,y=_yCutoff} , new Vector3{x=+10,y=_yCutoff} );
         Gizmos.color = Color.white; Gizmos.DrawRay( Vector3.zero , _In );
         Gizmos.color = Color.red; Gizmos.DrawRay( Vector3.zero , _Out );
     }
 }

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

Follow this Question

Answers Answers and Comments

139 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

Related Questions

Find Vector3 perpendicular to Vector3 A in direction of Vector3 B 1 Answer

Calculate collision between 2 rotated boxes without using BoxCollider (MATH) 2 Answers

Result of subtracton vectors 1 Answer

How would you fake air resistance? (c#) 2 Answers

How to get a weighted random Vector2 between 3 points 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