• 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
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
andrew-lukasik

People who like this

1 Show 0
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
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.w$$anonymous$$te; Gizmos.DrawRay( Vector3.zero , _In );
         Gizmos.color = Color.red; Gizmos.DrawRay( Vector3.zero , _Out );
     }
 }

Comment
$$anonymous$$

People who like this

1 Show 0 · 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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our 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

How to find an intercept on a moving target 2 Answers

Position between objects, vector math. 1 Answer

Changing the forward rotation for LookAt 2 Answers

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


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