A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Finding the normal vector of rotated object

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    3

    Finding the normal vector of rotated object

    Sorry if this subject is discussed already.
    I have a Sprite that is dynamically rotated and I want to find its normal vector.

    I couldn't resolve this problem only with flash native tools such as Vector3d, but if there exist such solution I prefer it than the pure mathematical one.

  2. #2
    Bacon-wrapped closures Nialsh's Avatar
    Join Date
    Dec 2003
    Location
    Houston!
    Posts
    338
    Normally sprites are 2D so I'm not sure what you would be doing with a 3D vector...

    Can you give an example of what you're doing?

  3. #3
    Junior Member
    Join Date
    Apr 2010
    Posts
    3
    In flash cs4 and latter Sprites become 3d objects when you give them value for z coordinat or rotationX, Y or Z

  4. #4
    Bacon-wrapped closures Nialsh's Avatar
    Join Date
    Dec 2003
    Location
    Houston!
    Posts
    338
    Interesting question. I think I figured something out.

    Let's say the normal vector for a flat sprite is pointing out of the page (ie. <0,0,-1>). You can use your the transformation matrix from your 3d-rotated sprite to transform that normal vector into its coordinates
    Code:
    var normalVec = sprite.transform.matrix3D.deltaTransformVector(new Vector3D(0,0,-1));
    which should yield the normal vector for the rotated sprite.

    And just a heads up: if you start scaling your sprite, the result of the above code will probably be a vector of length != 1.

  5. #5
    Junior Member
    Join Date
    Apr 2010
    Posts
    3
    Yes! Thanks, I don't quite understand how this works but it works (in my case with (0,0,1)).

    Strange why here
    they are using another more complex way to do this with sprite (child of the sprite that we are talking about), whit offset z = -100.
    I think yours is the correct way, thanks

  6. #6
    Junior Member
    Join Date
    Dec 2009
    Posts
    15
    http://help.adobe.com/en_US/AS3LCR/F.../Matrix3D.html

    The documentation shows how the basis is defined for the Matrix3D object. While transforming a unit vector pointing down the z-axis into the object's space is probably an okay way of thinking about it, the vector can be pulled directly out of the matrix. This vector will be unit length if no scaling takes place, as mentioned, and the set of vectors which define the basis will be mutually orthogonal if no skewing takes place.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center