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
1
Question by Tasarran · Sep 10, 2012 at 07:05 AM · rotatepixelsellipse

How can I rotate an elliptical cloud of points?

I have a function that draws on a texture in an airbrush style by picking a point using Random.insideUnitCircle, multiplying by the desired radius, and drawing the pixel. This runs several times in a loop.

If I want to distort this circle of points into an ellipse, I can multiply the x and y by different amounts.

Now, is there an easy way to rotate this ellipse of potential points forty-five degrees?

Pretty sure there is a quick solution to this; maybe some sort of matrix manipulation?

Comment
Add comment · Show 4
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 Tasarran · Sep 10, 2012 at 04:25 PM 1
Share

Fattie, you've jumped to the wrong conclusion... And with an extra note of condescension that makes your comment irritating, as well as useless.

Try re-reading it again, man.

I am generating random Vector2's, that if plotted on a texture, describe an ellipse.

These are not objects, nor are they part of another object, its just a bunch of number pairs...

I'm looking for a mathematical operation that I can apply to such a group of points.

avatar image Fattie · Sep 10, 2012 at 07:19 PM 0
Share

Well, I'm sorry you are so angry. In fact, it's a shame because you can do it exactly as I describe. Often you use empty game objects (think of it as a "calculation area") in exactly this way

Just do this..

make an empty object...
add each new point as a empty object at that point...

you're done, now rotate the object as you like. by any degrees. you can even skew it, etc. read off the points. it's no different from putting them in an array, and multiplying by sin

:O

Sorry you are so sore.

avatar image Tasarran · Sep 11, 2012 at 03:16 AM 0
Share

I think it might have been the part where you felt you needed to explain what 'easy as pie' meant... If you didn't mean to be snarky, I apologize.

avatar image Fattie · Sep 11, 2012 at 07:14 AM 0
Share

not at all ! I was just talking to someone else on this list who was asking about bizarre English phrases and so I explained it. "She'll be right mate!:" :)

2 Replies

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

Answer by MadDave · Sep 10, 2012 at 05:07 PM

http://en.wikipedia.org/wiki/Rotation_matrix

Unity has just a Matrix4x4 but you can easily extend your Vectors to four dimensions.

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 Tasarran · Sep 10, 2012 at 05:19 PM 1
Share

Yes, I think I just figured out how to do it more simply, yet more complicated...

Basically, what I need to do is create a 2x2 matrix in this manner:

cos(angle) -sin(angle)

sin(angle) cos(angle)

Then, you plug in the X and Y into this formula (breakdown of the product of a 2x2 and a 1x2 matrix):

For X: (cos(angle)*x) + (-sin(angle)*y)

For Y: (sin(angle)*x) + (cos(angle)*y)

For my rotation -45 degrees, the matrix looks like this:

0.707 0.707

-0.707 0.707

And my equations actually become:

For X: (0.707*x) + (0.707*y)

For Y: (-0.707*x) + (0.707*y)

This seems to work, plugging in 0,1 ends up with 0.707, 0.707, and plugging in 1,1 ends up with 1.414, 0...

avatar image Tasarran · Sep 10, 2012 at 05:32 PM 0
Share

And please allow me to add: I wish I had paid more attention in math class! I should have known this; and probably did, years ago. :)

avatar image save · Sep 10, 2012 at 05:38 PM 1
Share

Interesting! Thanks for sharing your solution @Tasarran.

avatar image Tasarran · Sep 10, 2012 at 05:58 PM 0
Share

This whole thing about matrices seems almost like magic... I think anyone who is program$$anonymous$$g should be aware of this, and how useful it can be!

Don't let the whole 4x4 matrix deal blow your $$anonymous$$d; it did to me at first, too. Start with trying to get the gist with a smaller matrix, like the basic 2D transforms (such as the rotation I describe above), and it will begin to crystallize... ;)

avatar image
1

Answer by Eric5h5 · Sep 10, 2012 at 10:29 PM

Personally I'm fond of using a transform to make Unity do all the math stuff:

 var points = [Vector2(0, 10), Vector2(5, 5)];
 transform.position = Vector3.zero;
 transform.eulerAngles = Vector3.forward * -45;
 var matrix = transform.localToWorldMatrix;
 for (point in points) point = matrix.MultiplyPoint3x4(point);
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

11 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

Related Questions

Camera rotation around player while following. 6 Answers

rotate smooth toward vector defined by controls 1 Answer

How do I animate a texture to rotate and loop around an imported object? 1 Answer

How can i rotate the aircraft elevator around the yellow axis up and down ?? as shown in the pic 0 Answers

camera rotate with limitation around x and y axis by using touch 0 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