
|
How to orbit to a point
|

|
Re: How to orbit to a point
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. -- [ JPG ]
_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org
|

|
Re: How to orbit to a point
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.
-- [ JPG ]
_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org
-- http://lyraspace.comhttp://blog.lyraspace.comhttp://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
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
-- http://lyraspace.comhttp://blog.lyraspace.comhttp://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
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
-- http://lyraspace.comhttp://blog.lyraspace.comhttp://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
|

|
Re: How to orbit to a point
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
-- http://lyraspace.comhttp://blog.lyraspace.comhttp://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.comhttp://blog.lyraspace.comhttp://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
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
-- http://lyraspace.comhttp://blog.lyraspace.comhttp://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.comhttp://blog.lyraspace.comhttp://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
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.
-- http://lyraspace.comhttp://blog.lyraspace.comhttp://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.comhttp://blog.lyraspace.comhttp://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
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).
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.
-- http://lyraspace.comhttp://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.comhttp://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.comhttp://blog.lyraspace.comhttp://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
|

|
Re: How to orbit to a point
|

|
Re: How to orbit to a point
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).
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. -- http://lyraspace.comhttp://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.comhttp://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.comhttp://blog.lyraspace.comhttp://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
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).
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.
-- http://lyraspace.comhttp://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.comhttp://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.comhttp://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.comhttp://blog.lyraspace.comhttp://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
|