How to orbit to a point

View: New views
14 Messages — Rating Filter:   Alert me  

How to orbit to a point

by Lee Probert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Can someone give me an example of the math I need to get an object to move in an orbit towards another point in 3D space. I think it has something to do with Quaternions. I want the object to point towards the target as well.

Thanks, Lee. 

--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by John Grden-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

if youdon't mind parenting the object that needs to "orbit", you can simply do that.

Or, you can easily do it with out that silly math crap in your render loop:

my3Dobj.x = my3Dobj.y = my3Dobj.z = 0; // or set it to the point in 3D space you want
my3Dobj.yaw(1); // rotate object
my3Dobj.moveBackward(1000);// or whatever distance the orbit is

then render

yay!  orbit.

On Thu, Nov 5, 2009 at 5:50 AM, Lee Probert <leeprobert@...> wrote:
Can someone give me an example of the math I need to get an object to move in an orbit towards another point in 3D space. I think it has something to do with Quaternions. I want the object to point towards the target as well.

Thanks, Lee. 

--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by Lee Probert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi John. Thanks for the response. I'm trying to create a 3D version of the 'Swarm' class from Joshua and Branden's new Hype framework. At the moment the way this works (in 2D) is that each object has a target point that it tries to get to but it attempts to get there by following a circular path which has a bit of randomness to it to create a motion 'behaviour' that you can tweak. This is the code for doing that in 2D :

var clip:DisplayObject = target as DisplayObject;

var angle:Number = Math.atan2(_point.y - clip.y, _point.x - clip.x) * HypeMath.R2D;

var deltaAngle:Number = HypeMath.getDegreeDistance(clip.rotation, angle);

clip.rotation += deltaAngle * _turnEase + (Math.random() * _twitch * 2) - _twitch;

clip.x += Math.cos(clip.rotation * HypeMath.D2R) * _speed;

clip.y += Math.sin(clip.rotation * HypeMath.D2R) * _speed;


... what I'd like to do is mimic this by introducing the Z. I guess I need to work out the angle to the target point and then set the object off on an orbit from its current location to the new target.


My math is pretty poor. Any help or pointers would be appreciated.


My experiments so far with this are here : http://rezzynet.com



On Thu, Nov 5, 2009 at 2:02 PM, John Grden <neoriley@...> wrote:
if youdon't mind parenting the object that needs to "orbit", you can simply do that.

Or, you can easily do it with out that silly math crap in your render loop:

my3Dobj.x = my3Dobj.y = my3Dobj.z = 0; // or set it to the point in 3D space you want
my3Dobj.yaw(1); // rotate object
my3Dobj.moveBackward(1000);// or whatever distance the orbit is

then render

yay!  orbit.

On Thu, Nov 5, 2009 at 5:50 AM, Lee Probert <leeprobert@...> wrote:
Can someone give me an example of the math I need to get an object to move in an orbit towards another point in 3D space. I think it has something to do with Quaternions. I want the object to point towards the target as well.

Thanks, Lee. 

--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by Lee Probert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

BTW ... this post is the closest thing I've found to what I need to do (I think) ... http://blog.zupko.info/?p=221

Although I think this may be over-complicating the matter too much.

:-)


On Thu, Nov 5, 2009 at 2:13 PM, Lee Probert <leeprobert@...> wrote:
Hi John. Thanks for the response. I'm trying to create a 3D version of the 'Swarm' class from Joshua and Branden's new Hype framework. At the moment the way this works (in 2D) is that each object has a target point that it tries to get to but it attempts to get there by following a circular path which has a bit of randomness to it to create a motion 'behaviour' that you can tweak. This is the code for doing that in 2D :

var clip:DisplayObject = target as DisplayObject;

var angle:Number = Math.atan2(_point.y - clip.y, _point.x - clip.x) * HypeMath.R2D;

var deltaAngle:Number = HypeMath.getDegreeDistance(clip.rotation, angle);

clip.rotation += deltaAngle * _turnEase + (Math.random() * _twitch * 2) - _twitch;

clip.x += Math.cos(clip.rotation * HypeMath.D2R) * _speed;

clip.y += Math.sin(clip.rotation * HypeMath.D2R) * _speed;


... what I'd like to do is mimic this by introducing the Z. I guess I need to work out the angle to the target point and then set the object off on an orbit from its current location to the new target.


My math is pretty poor. Any help or pointers would be appreciated.


My experiments so far with this are here : http://rezzynet.com



On Thu, Nov 5, 2009 at 2:02 PM, John Grden <neoriley@...> wrote:
if youdon't mind parenting the object that needs to "orbit", you can simply do that.

Or, you can easily do it with out that silly math crap in your render loop:

my3Dobj.x = my3Dobj.y = my3Dobj.z = 0; // or set it to the point in 3D space you want
my3Dobj.yaw(1); // rotate object
my3Dobj.moveBackward(1000);// or whatever distance the orbit is

then render

yay!  orbit.

On Thu, Nov 5, 2009 at 5:50 AM, Lee Probert <leeprobert@...> wrote:
Can someone give me an example of the math I need to get an object to move in an orbit towards another point in 3D space. I think it has something to do with Quaternions. I want the object to point towards the target as well.

Thanks, Lee. 

--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN



--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by John Grden-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

lol funny that andy's blog is the one you pointed to, I was just about to say "Ask Andy"

On Thu, Nov 5, 2009 at 9:21 AM, Lee Probert <leeprobert@...> wrote:
BTW ... this post is the closest thing I've found to what I need to do (I think) ... http://blog.zupko.info/?p=221

Although I think this may be over-complicating the matter too much.

:-)


On Thu, Nov 5, 2009 at 2:13 PM, Lee Probert <leeprobert@...> wrote:
Hi John. Thanks for the response. I'm trying to create a 3D version of the 'Swarm' class from Joshua and Branden's new Hype framework. At the moment the way this works (in 2D) is that each object has a target point that it tries to get to but it attempts to get there by following a circular path which has a bit of randomness to it to create a motion 'behaviour' that you can tweak. This is the code for doing that in 2D :

var clip:DisplayObject = target as DisplayObject;

var angle:Number = Math.atan2(_point.y - clip.y, _point.x - clip.x) * HypeMath.R2D;

var deltaAngle:Number = HypeMath.getDegreeDistance(clip.rotation, angle);

clip.rotation += deltaAngle * _turnEase + (Math.random() * _twitch * 2) - _twitch;

clip.x += Math.cos(clip.rotation * HypeMath.D2R) * _speed;

clip.y += Math.sin(clip.rotation * HypeMath.D2R) * _speed;


... what I'd like to do is mimic this by introducing the Z. I guess I need to work out the angle to the target point and then set the object off on an orbit from its current location to the new target.


My math is pretty poor. Any help or pointers would be appreciated.


My experiments so far with this are here : http://rezzynet.com



On Thu, Nov 5, 2009 at 2:02 PM, John Grden <neoriley@...> wrote:
if youdon't mind parenting the object that needs to "orbit", you can simply do that.

Or, you can easily do it with out that silly math crap in your render loop:

my3Dobj.x = my3Dobj.y = my3Dobj.z = 0; // or set it to the point in 3D space you want
my3Dobj.yaw(1); // rotate object
my3Dobj.moveBackward(1000);// or whatever distance the orbit is

then render

yay!  orbit.

On Thu, Nov 5, 2009 at 5:50 AM, Lee Probert <leeprobert@...> wrote:
Can someone give me an example of the math I need to get an object to move in an orbit towards another point in 3D space. I think it has something to do with Quaternions. I want the object to point towards the target as well.

Thanks, Lee. 

--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN



--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by John3210 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Lee,

The graphics are stunning.

John


Lee Probert wrote:

> Can someone give me an example of the math I need to get an object to
> move in an orbit towards another point in 3D space. I think it has
> something to do with Quaternions. I want the object to point towards
> the target as well.
>
> Thanks, Lee.
>
> --
> http://lyraspace.com
> http://blog.lyraspace.com
> http://rezzynet.com
>
> info@... <mailto:info@...>
> skype: lee.probert
> google/MSN : leeprobert@... <mailto:leeprobert@...>
> twitter : @lyraspace
> tel: 01892 837 654
> mob: 07540 723783 <-- NEW
> 24 Allington Road,
> Paddock Wood,
> Tonbridge,
> Kent.
> TN12 6AN
> ------------------------------------------------------------------------
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D@...
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>  



_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by Lee Probert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yea, I did ... well I left a comment on that post anyway. I'll keep on trucking then and see what I can cobble together.

Thanks! (LOL ... I read your blog)



On Thu, Nov 5, 2009 at 2:25 PM, John Grden <neoriley@...> wrote:
lol funny that andy's blog is the one you pointed to, I was just about to say "Ask Andy"


On Thu, Nov 5, 2009 at 9:21 AM, Lee Probert <leeprobert@...> wrote:
BTW ... this post is the closest thing I've found to what I need to do (I think) ... http://blog.zupko.info/?p=221

Although I think this may be over-complicating the matter too much.

:-)


On Thu, Nov 5, 2009 at 2:13 PM, Lee Probert <leeprobert@...> wrote:
Hi John. Thanks for the response. I'm trying to create a 3D version of the 'Swarm' class from Joshua and Branden's new Hype framework. At the moment the way this works (in 2D) is that each object has a target point that it tries to get to but it attempts to get there by following a circular path which has a bit of randomness to it to create a motion 'behaviour' that you can tweak. This is the code for doing that in 2D :

var clip:DisplayObject = target as DisplayObject;

var angle:Number = Math.atan2(_point.y - clip.y, _point.x - clip.x) * HypeMath.R2D;

var deltaAngle:Number = HypeMath.getDegreeDistance(clip.rotation, angle);

clip.rotation += deltaAngle * _turnEase + (Math.random() * _twitch * 2) - _twitch;

clip.x += Math.cos(clip.rotation * HypeMath.D2R) * _speed;

clip.y += Math.sin(clip.rotation * HypeMath.D2R) * _speed;


... what I'd like to do is mimic this by introducing the Z. I guess I need to work out the angle to the target point and then set the object off on an orbit from its current location to the new target.


My math is pretty poor. Any help or pointers would be appreciated.


My experiments so far with this are here : http://rezzynet.com



On Thu, Nov 5, 2009 at 2:02 PM, John Grden <neoriley@...> wrote:
if youdon't mind parenting the object that needs to "orbit", you can simply do that.

Or, you can easily do it with out that silly math crap in your render loop:

my3Dobj.x = my3Dobj.y = my3Dobj.z = 0; // or set it to the point in 3D space you want
my3Dobj.yaw(1); // rotate object
my3Dobj.moveBackward(1000);// or whatever distance the orbit is

then render

yay!  orbit.

On Thu, Nov 5, 2009 at 5:50 AM, Lee Probert <leeprobert@...> wrote:
Can someone give me an example of the math I need to get an object to move in an orbit towards another point in 3D space. I think it has something to do with Quaternions. I want the object to point towards the target as well.

Thanks, Lee. 

--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN



--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by John Grden-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

yeah if math is your need, Andy's your man ;)

On Thu, Nov 5, 2009 at 9:30 AM, Lee Probert <leeprobert@...> wrote:
Yea, I did ... well I left a comment on that post anyway. I'll keep on trucking then and see what I can cobble together.

Thanks! (LOL ... I read your blog)



On Thu, Nov 5, 2009 at 2:25 PM, John Grden <neoriley@...> wrote:
lol funny that andy's blog is the one you pointed to, I was just about to say "Ask Andy"


On Thu, Nov 5, 2009 at 9:21 AM, Lee Probert <leeprobert@...> wrote:
BTW ... this post is the closest thing I've found to what I need to do (I think) ... http://blog.zupko.info/?p=221

Although I think this may be over-complicating the matter too much.

:-)


On Thu, Nov 5, 2009 at 2:13 PM, Lee Probert <leeprobert@...> wrote:
Hi John. Thanks for the response. I'm trying to create a 3D version of the 'Swarm' class from Joshua and Branden's new Hype framework. At the moment the way this works (in 2D) is that each object has a target point that it tries to get to but it attempts to get there by following a circular path which has a bit of randomness to it to create a motion 'behaviour' that you can tweak. This is the code for doing that in 2D :

var clip:DisplayObject = target as DisplayObject;

var angle:Number = Math.atan2(_point.y - clip.y, _point.x - clip.x) * HypeMath.R2D;

var deltaAngle:Number = HypeMath.getDegreeDistance(clip.rotation, angle);

clip.rotation += deltaAngle * _turnEase + (Math.random() * _twitch * 2) - _twitch;

clip.x += Math.cos(clip.rotation * HypeMath.D2R) * _speed;

clip.y += Math.sin(clip.rotation * HypeMath.D2R) * _speed;


... what I'd like to do is mimic this by introducing the Z. I guess I need to work out the angle to the target point and then set the object off on an orbit from its current location to the new target.


My math is pretty poor. Any help or pointers would be appreciated.


My experiments so far with this are here : http://rezzynet.com



On Thu, Nov 5, 2009 at 2:02 PM, John Grden <neoriley@...> wrote:
if youdon't mind parenting the object that needs to "orbit", you can simply do that.

Or, you can easily do it with out that silly math crap in your render loop:

my3Dobj.x = my3Dobj.y = my3Dobj.z = 0; // or set it to the point in 3D space you want
my3Dobj.yaw(1); // rotate object
my3Dobj.moveBackward(1000);// or whatever distance the orbit is

then render

yay!  orbit.

On Thu, Nov 5, 2009 at 5:50 AM, Lee Probert <leeprobert@...> wrote:
Can someone give me an example of the math I need to get an object to move in an orbit towards another point in 3D space. I think it has something to do with Quaternions. I want the object to point towards the target as well.

Thanks, Lee. 

--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN



--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by Andy Zupko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just use camera.orbit(pitch, yaw) where those are absolute values of where the camera should be around an object.

0, 0 is the top of the object (straight up), so to rotate around the objects side:

camera.orbit(90, yaw++); //onEnterFrame

position the camera the distance you want from the object prior to calling this.


Quats and such aren't the best/fastest solution here :P


-andy

On Nov 5, 2009, at 8:37 AM, John Grden wrote:

yeah if math is your need, Andy's your man ;)

On Thu, Nov 5, 2009 at 9:30 AM, Lee Probert <leeprobert@...> wrote:
Yea, I did ... well I left a comment on that post anyway. I'll keep on trucking then and see what I can cobble together.

Thanks! (LOL ... I read your blog)



On Thu, Nov 5, 2009 at 2:25 PM, John Grden <neoriley@...> wrote:
lol funny that andy's blog is the one you pointed to, I was just about to say "Ask Andy"


On Thu, Nov 5, 2009 at 9:21 AM, Lee Probert <leeprobert@...> wrote:
BTW ... this post is the closest thing I've found to what I need to do (I think) ... http://blog.zupko.info/?p=221

Although I think this may be over-complicating the matter too much.

:-)


On Thu, Nov 5, 2009 at 2:13 PM, Lee Probert <leeprobert@...> wrote:
Hi John. Thanks for the response. I'm trying to create a 3D version of the 'Swarm' class from Joshua and Branden's new Hype framework. At the moment the way this works (in 2D) is that each object has a target point that it tries to get to but it attempts to get there by following a circular path which has a bit of randomness to it to create a motion 'behaviour' that you can tweak. This is the code for doing that in 2D :

var clip:DisplayObject = target as DisplayObject;
var angle:Number = Math.atan2(_point.y - clip.y, _point.x - clip.x) * HypeMath.R2D;
var deltaAngle:Number = HypeMath.getDegreeDistance(clip.rotation, angle);


clip.rotation += deltaAngle * _turnEase + (Math.random() * _twitch * 2) - _twitch;
clip.x += Math.cos(clip.rotation * HypeMath.D2R) * _speed;
clip.y += Math.sin(clip.rotation * HypeMath.D2R) * _speed;

... what I'd like to do is mimic this by introducing the Z. I guess I need to work out the angle to the target point and then set the object off on an orbit from its current location to the new target.

My math is pretty poor. Any help or pointers would be appreciated.

My experiments so far with this are here : http://rezzynet.com


On Thu, Nov 5, 2009 at 2:02 PM, John Grden <neoriley@...> wrote:
if youdon't mind parenting the object that needs to "orbit", you can simply do that.

Or, you can easily do it with out that silly math crap in your render loop:

my3Dobj.x = my3Dobj.y = my3Dobj.z = 0; // or set it to the point in 3D space you want
my3Dobj.yaw(1); // rotate object
my3Dobj.moveBackward(1000);// or whatever distance the orbit is

then render

yay!  orbit.

On Thu, Nov 5, 2009 at 5:50 AM, Lee Probert <leeprobert@...> wrote:
Can someone give me an example of the math I need to get an object to move in an orbit towards another point in 3D space. I think it has something to do with Quaternions. I want the object to point towards the target as well.

Thanks, Lee. 

--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN



--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]
_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org


_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by Lee Probert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Andy. This is slightly more complicated than it at first appears although I'm sure you would have a very elegant solution. The simplest way to describe the problem is like so ...

I have objects being spawned that then need to point to a target in 3D space and start to travel to this point but not directly. Their behaviour needs to appear erratic so I am attempting to move them in an arc towards this point. I don't want to tween on a bezier because a few ticks later they need to change course slightly (but still heading towards the target).

This is a 3D version of the Swarm class in the new Hype framework. My first experiment is located here : http://rezzynet.com/swarm/Main.html

Imagine firing a missile from one point to another but the missile is drunk!

:-)


On Thu, Nov 5, 2009 at 3:11 PM, Andy Zupko <azupko@...> wrote:
Just use camera.orbit(pitch, yaw) where those are absolute values of where the camera should be around an object.

0, 0 is the top of the object (straight up), so to rotate around the objects side:

camera.orbit(90, yaw++); //onEnterFrame

position the camera the distance you want from the object prior to calling this.


Quats and such aren't the best/fastest solution here :P


-andy

On Nov 5, 2009, at 8:37 AM, John Grden wrote:

yeah if math is your need, Andy's your man ;)

On Thu, Nov 5, 2009 at 9:30 AM, Lee Probert <leeprobert@...> wrote:
Yea, I did ... well I left a comment on that post anyway. I'll keep on trucking then and see what I can cobble together.

Thanks! (LOL ... I read your blog)



On Thu, Nov 5, 2009 at 2:25 PM, John Grden <neoriley@...> wrote:
lol funny that andy's blog is the one you pointed to, I was just about to say "Ask Andy"


On Thu, Nov 5, 2009 at 9:21 AM, Lee Probert <leeprobert@...> wrote:
BTW ... this post is the closest thing I've found to what I need to do (I think) ... http://blog.zupko.info/?p=221

Although I think this may be over-complicating the matter too much.

:-)


On Thu, Nov 5, 2009 at 2:13 PM, Lee Probert <leeprobert@...> wrote:
Hi John. Thanks for the response. I'm trying to create a 3D version of the 'Swarm' class from Joshua and Branden's new Hype framework. At the moment the way this works (in 2D) is that each object has a target point that it tries to get to but it attempts to get there by following a circular path which has a bit of randomness to it to create a motion 'behaviour' that you can tweak. This is the code for doing that in 2D :

var clip:DisplayObject = target as DisplayObject;
var angle:Number = Math.atan2(_point.y - clip.y, _point.x - clip.x) * HypeMath.R2D;
var deltaAngle:Number = HypeMath.getDegreeDistance(clip.rotation, angle);


clip.rotation += deltaAngle * _turnEase + (Math.random() * _twitch * 2) - _twitch;
clip.x += Math.cos(clip.rotation * HypeMath.D2R) * _speed;
clip.y += Math.sin(clip.rotation * HypeMath.D2R) * _speed;

... what I'd like to do is mimic this by introducing the Z. I guess I need to work out the angle to the target point and then set the object off on an orbit from its current location to the new target.

My math is pretty poor. Any help or pointers would be appreciated.

My experiments so far with this are here : http://rezzynet.com


On Thu, Nov 5, 2009 at 2:02 PM, John Grden <neoriley@...> wrote:
if youdon't mind parenting the object that needs to "orbit", you can simply do that.

Or, you can easily do it with out that silly math crap in your render loop:

my3Dobj.x = my3Dobj.y = my3Dobj.z = 0; // or set it to the point in 3D space you want
my3Dobj.yaw(1); // rotate object
my3Dobj.moveBackward(1000);// or whatever distance the orbit is

then render

yay!  orbit.

On Thu, Nov 5, 2009 at 5:50 AM, Lee Probert <leeprobert@...> wrote:
Can someone give me an example of the math I need to get an object to move in an orbit towards another point in 3D space. I think it has something to do with Quaternions. I want the object to point towards the target as well.

Thanks, Lee. 

--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN



--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]
_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org


_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by Strange Loop Studios :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey Lee,

I've just checked out your experiments site and noticed you're doing some
audio visualizations with PV. Cool! Me to, when i get time...
I've actually started to create a bit of a framework for audio visuals
including PV and might be able to help you make your animations a lot more
responsive across all frequencies bands.

Here's some of my older experiments pre framework - for inspiration!

http://deceptiveresolution.wordpress.com/2009/09/01/visualizing-an-rtmp-flv/
http://deceptiveresolution.wordpress.com/2008/10/15/sexed-up-as3-visualization/
http://deceptiveresolution.wordpress.com/2008/10/07/the-seed-of-a-big-idea/
http://www.strangeloopstudios.com/experiments/3dmp3/

If you want to chat about this or perhaps do some work together drop me a
mail.

Nice work
Doug

----- Original Message -----
From: "John McCormack" <john@...>
To: <papervision3d@...>
Sent: Thursday, November 05, 2009 2:29 PM
Subject: Re: [Papervision3D] How to orbit to a point


> Lee,
>
> The graphics are stunning.
>
> John
>
>
> Lee Probert wrote:
>> Can someone give me an example of the math I need to get an object to
>> move in an orbit towards another point in 3D space. I think it has
>> something to do with Quaternions. I want the object to point towards the
>> target as well.
>>
>> Thanks, Lee.
>> --
>> http://lyraspace.com
>> http://blog.lyraspace.com
>> http://rezzynet.com
>>
>> info@... <mailto:info@...>
>> skype: lee.probert
>> google/MSN : leeprobert@... <mailto:leeprobert@...>
>> twitter : @lyraspace
>> tel: 01892 837 654
>> mob: 07540 723783 <-- NEW
>> 24 Allington Road,
>> Paddock Wood,
>> Tonbridge,
>> Kent.
>> TN12 6AN
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Papervision3D mailing list
>> Papervision3D@...
>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>
>
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D@...
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>



_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by Lee Probert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey Doug. Thanks for these links. I'll be in touch.

:-)


On Thu, Nov 5, 2009 at 3:31 PM, Strange Loop Studios <info@...> wrote:
Hey Lee,

I've just checked out your experiments site and noticed you're doing some audio visualizations with PV. Cool! Me to, when i get time...
I've actually started to create a bit of a framework for audio visuals including PV and might be able to help you make your animations a lot more responsive across all frequencies bands.

Here's some of my older experiments pre framework - for inspiration!

http://deceptiveresolution.wordpress.com/2009/09/01/visualizing-an-rtmp-flv/
http://deceptiveresolution.wordpress.com/2008/10/15/sexed-up-as3-visualization/
http://deceptiveresolution.wordpress.com/2008/10/07/the-seed-of-a-big-idea/
http://www.strangeloopstudios.com/experiments/3dmp3/

If you want to chat about this or perhaps do some work together drop me a mail.

Nice work
Doug

----- Original Message ----- From: "John McCormack" <john@...>
To: <papervision3d@...>
Sent: Thursday, November 05, 2009 2:29 PM
Subject: Re: [Papervision3D] How to orbit to a point



Lee,

The graphics are stunning.

John


Lee Probert wrote:
Can someone give me an example of the math I need to get an object to move in an orbit towards another point in 3D space. I think it has something to do with Quaternions. I want the object to point towards the target as well.

Thanks, Lee.
--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@... <mailto:info@...>
skype: lee.probert
google/MSN : leeprobert@... <mailto:leeprobert@...>
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN
------------------------------------------------------------------------

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org





_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org



--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by Andy Zupko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Easiest way to get an "arc" nicely to something is to get each object its own velocity.   ie:

var dx = targetX-object.x;

vX += dx.x * 0.01; 
// 0.01 = some arbitrary number on how fast you want it to go - it will go faster the further away the object is.
// Another approach is to use direction and not total distance, just depends what you want.  This will slow as it gets closer.

object.x += vX;

vX *= 0.95; //  arbitrary number on how fast you want to dampen the motion - bigger number is longer to slow

do that for dy and dz as well.

Playing wtih the scale and damp will let your objects overshoot, bounce back, etc.





On Nov 5, 2009, at 9:21 AM, Lee Probert wrote:

Hi Andy. This is slightly more complicated than it at first appears although I'm sure you would have a very elegant solution. The simplest way to describe the problem is like so ...

I have objects being spawned that then need to point to a target in 3D space and start to travel to this point but not directly. Their behaviour needs to appear erratic so I am attempting to move them in an arc towards this point. I don't want to tween on a bezier because a few ticks later they need to change course slightly (but still heading towards the target).

This is a 3D version of the Swarm class in the new Hype framework. My first experiment is located here : http://rezzynet.com/swarm/Main.html

Imagine firing a missile from one point to another but the missile is drunk!

:-)


On Thu, Nov 5, 2009 at 3:11 PM, Andy Zupko <azupko@...> wrote:
Just use camera.orbit(pitch, yaw) where those are absolute values of where the camera should be around an object.

0, 0 is the top of the object (straight up), so to rotate around the objects side:

camera.orbit(90, yaw++); //onEnterFrame

position the camera the distance you want from the object prior to calling this.


Quats and such aren't the best/fastest solution here :P


-andy

On Nov 5, 2009, at 8:37 AM, John Grden wrote:

yeah if math is your need, Andy's your man ;)

On Thu, Nov 5, 2009 at 9:30 AM, Lee Probert <leeprobert@...> wrote:
Yea, I did ... well I left a comment on that post anyway. I'll keep on trucking then and see what I can cobble together.

Thanks! (LOL ... I read your blog)



On Thu, Nov 5, 2009 at 2:25 PM, John Grden <neoriley@...> wrote:
lol funny that andy's blog is the one you pointed to, I was just about to say "Ask Andy"


On Thu, Nov 5, 2009 at 9:21 AM, Lee Probert <leeprobert@...> wrote:
BTW ... this post is the closest thing I've found to what I need to do (I think) ... http://blog.zupko.info/?p=221

Although I think this may be over-complicating the matter too much.

:-)


On Thu, Nov 5, 2009 at 2:13 PM, Lee Probert <leeprobert@...> wrote:
Hi John. Thanks for the response. I'm trying to create a 3D version of the 'Swarm' class from Joshua and Branden's new Hype framework. At the moment the way this works (in 2D) is that each object has a target point that it tries to get to but it attempts to get there by following a circular path which has a bit of randomness to it to create a motion 'behaviour' that you can tweak. This is the code for doing that in 2D :

var clip:DisplayObject = target as DisplayObject;
var angle:Number = Math.atan2(_point.y - clip.y, _point.x - clip.x) * HypeMath.R2D;
var deltaAngle:Number = HypeMath.getDegreeDistance(clip.rotation, angle);

clip.rotation += deltaAngle * _turnEase + (Math.random() * _twitch * 2) - _twitch;
clip.x += Math.cos(clip.rotation * HypeMath.D2R) * _speed;
clip.y += Math.sin(clip.rotation * HypeMath.D2R) * _speed;

... what I'd like to do is mimic this by introducing the Z. I guess I need to work out the angle to the target point and then set the object off on an orbit from its current location to the new target.

My math is pretty poor. Any help or pointers would be appreciated.

My experiments so far with this are here : http://rezzynet.com


On Thu, Nov 5, 2009 at 2:02 PM, John Grden <neoriley@...> wrote:
if youdon't mind parenting the object that needs to "orbit", you can simply do that.

Or, you can easily do it with out that silly math crap in your render loop:

my3Dobj.x = my3Dobj.y = my3Dobj.z = 0; // or set it to the point in 3D space you want
my3Dobj.yaw(1); // rotate object
my3Dobj.moveBackward(1000);// or whatever distance the orbit is

then render

yay!  orbit.

On Thu, Nov 5, 2009 at 5:50 AM, Lee Probert <leeprobert@...> wrote:
Can someone give me an example of the math I need to get an object to move in an orbit towards another point in 3D space. I think it has something to do with Quaternions. I want the object to point towards the target as well.

Thanks, Lee. 

--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN



--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]
_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org


_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN
_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org


_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: How to orbit to a point

by Lee Probert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I posted this earlier for John. This is the 2D implementation of what I need ...

var clip:DisplayObject = target as DisplayObject;

var angle:Number = Math.atan2(_point.y - clip.y, _point.x - clip.x) * HypeMath.R2D;

var deltaAngle:Number = HypeMath.getDegreeDistance(clip.rotation, angle);

clip.rotation += deltaAngle * _turnEase + (Math.random() * _twitch * 2) - _twitch;

clip.x += Math.cos(clip.rotation * HypeMath.D2R) * _speed;

clip.y += Math.sin(clip.rotation * HypeMath.D2R) * _speed;


This code is run on an interval and the result is that the object (in 2D) attempts to orbit its target point while gradually moving towards it. The twitch value also makes the object move erratically.


I know from reading your blog that attempting to use cos and sin on the XY and XZ will not give me the results I need to achieve the same results. This is why I thought there may be a better way.


I'll try your suggested technique but if you do think there is a more mathematically elegant solution then I'd love to hear about it.


A good start would be the code to make an object rotate towards an arbitrary point.


thank you, Lee.



On Thu, Nov 5, 2009 at 4:22 PM, Andy Zupko <azupko@...> wrote:
Easiest way to get an "arc" nicely to something is to get each object its own velocity.   ie:

var dx = targetX-object.x;

vX += dx.x * 0.01; 
// 0.01 = some arbitrary number on how fast you want it to go - it will go faster the further away the object is.
// Another approach is to use direction and not total distance, just depends what you want.  This will slow as it gets closer.

object.x += vX;

vX *= 0.95; //  arbitrary number on how fast you want to dampen the motion - bigger number is longer to slow

do that for dy and dz as well.

Playing wtih the scale and damp will let your objects overshoot, bounce back, etc.





On Nov 5, 2009, at 9:21 AM, Lee Probert wrote:

Hi Andy. This is slightly more complicated than it at first appears although I'm sure you would have a very elegant solution. The simplest way to describe the problem is like so ...

I have objects being spawned that then need to point to a target in 3D space and start to travel to this point but not directly. Their behaviour needs to appear erratic so I am attempting to move them in an arc towards this point. I don't want to tween on a bezier because a few ticks later they need to change course slightly (but still heading towards the target).

This is a 3D version of the Swarm class in the new Hype framework. My first experiment is located here : http://rezzynet.com/swarm/Main.html

Imagine firing a missile from one point to another but the missile is drunk!

:-)


On Thu, Nov 5, 2009 at 3:11 PM, Andy Zupko <azupko@...> wrote:
Just use camera.orbit(pitch, yaw) where those are absolute values of where the camera should be around an object.

0, 0 is the top of the object (straight up), so to rotate around the objects side:

camera.orbit(90, yaw++); //onEnterFrame

position the camera the distance you want from the object prior to calling this.


Quats and such aren't the best/fastest solution here :P


-andy

On Nov 5, 2009, at 8:37 AM, John Grden wrote:

yeah if math is your need, Andy's your man ;)

On Thu, Nov 5, 2009 at 9:30 AM, Lee Probert <leeprobert@...> wrote:
Yea, I did ... well I left a comment on that post anyway. I'll keep on trucking then and see what I can cobble together.

Thanks! (LOL ... I read your blog)



On Thu, Nov 5, 2009 at 2:25 PM, John Grden <neoriley@...> wrote:
lol funny that andy's blog is the one you pointed to, I was just about to say "Ask Andy"


On Thu, Nov 5, 2009 at 9:21 AM, Lee Probert <leeprobert@...> wrote:
BTW ... this post is the closest thing I've found to what I need to do (I think) ... http://blog.zupko.info/?p=221

Although I think this may be over-complicating the matter too much.

:-)


On Thu, Nov 5, 2009 at 2:13 PM, Lee Probert <leeprobert@...> wrote:
Hi John. Thanks for the response. I'm trying to create a 3D version of the 'Swarm' class from Joshua and Branden's new Hype framework. At the moment the way this works (in 2D) is that each object has a target point that it tries to get to but it attempts to get there by following a circular path which has a bit of randomness to it to create a motion 'behaviour' that you can tweak. This is the code for doing that in 2D :

var clip:DisplayObject = target as DisplayObject;
var angle:Number = Math.atan2(_point.y - clip.y, _point.x - clip.x) * HypeMath.R2D;
var deltaAngle:Number = HypeMath.getDegreeDistance(clip.rotation, angle);

clip.rotation += deltaAngle * _turnEase + (Math.random() * _twitch * 2) - _twitch;
clip.x += Math.cos(clip.rotation * HypeMath.D2R) * _speed;
clip.y += Math.sin(clip.rotation * HypeMath.D2R) * _speed;

... what I'd like to do is mimic this by introducing the Z. I guess I need to work out the angle to the target point and then set the object off on an orbit from its current location to the new target.

My math is pretty poor. Any help or pointers would be appreciated.

My experiments so far with this are here : http://rezzynet.com


On Thu, Nov 5, 2009 at 2:02 PM, John Grden <neoriley@...> wrote:
if youdon't mind parenting the object that needs to "orbit", you can simply do that.

Or, you can easily do it with out that silly math crap in your render loop:

my3Dobj.x = my3Dobj.y = my3Dobj.z = 0; // or set it to the point in 3D space you want
my3Dobj.yaw(1); // rotate object
my3Dobj.moveBackward(1000);// or whatever distance the orbit is

then render

yay!  orbit.

On Thu, Nov 5, 2009 at 5:50 AM, Lee Probert <leeprobert@...> wrote:
Can someone give me an example of the math I need to get an object to move in an orbit towards another point in 3D space. I think it has something to do with Quaternions. I want the object to point towards the target as well.

Thanks, Lee. 

--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN



--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
[  JPG  ]
_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org


_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN
_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org


_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




--
http://lyraspace.com
http://blog.lyraspace.com
http://rezzynet.com

info@...
skype: lee.probert
google/MSN : leeprobert@...
twitter : @lyraspace
tel: 01892 837 654
mob: 07540 723783 <-- NEW
24 Allington Road,
Paddock Wood,
Tonbridge,
Kent.
TN12 6AN

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org