## Thread## Board Archives## Site Features## Activeworlds Support## Historic Archives |
AWCPP - C++ release v0.2 (Sdk)
## AWCPP - C++ release v0.2 // Sdk## edward sumerfieldOct 24, 1998, 5:13am
This is version 0.2 of the C++ wrapper for the Active Worlds SDK.
The coolest change is the movement classes. I have removed the need to use x,y and z coordinates and in their place you can rotate left, rigth, up and down and then move forward. With the up and down it is even supporting pitch so you can set the robot position as 0 x coord, 0 z coord, 0 altitude, 0 yaw and 45 pitch. Now if you call the forward method the avatar will ascend into the sky at a 45 degree angle for the distance specified. It makes it very easy to do things like move the robot round in circles: for (int a = 0; a < 24;a++) { rotate_left(15); // 15 degrees forward(1); // 1 meter } I standardized all the units to degrees and meters so there are no ugle translations anywhere. Here is the web page where you can download it from: http://members.xoom.com/esumerfd/ActiveWorlds/AWSDK.htm I have split the source and binaries up since the total download was getting a little large. The next steps are: 1. Add guesture support to the movement class. 2. Add more functionality to the avatar_add callback so you get more informtation about the avatar added. 3. Look at building a Movement derivitive that works in conjunction with avatar_add and allows a robot to see someone and run away. Every day, in every way, I get closer to my field of deer. Though I guess I am going to be limited to 3 to begin with. Doh. Maybe thats a herdette of deer. Edward Sumerfield. ## walter knupeOct 24, 1998, 7:57pm
Why did you write all this after i needed it ? i had to get out my math book
to find how to translate polar and carthesian coordinates :) and moving in cirlces seems to be everyones dream (besides deer, that is) since i did it similar :) Walter Edward Sumerfield schrieb in Nachricht <36317e55.0 at homer>... >This is version 0.2 of the C++ wrapper for the Active Worlds SDK. > >The coolest change is the movement classes. I have removed the need to use >x,y and z coordinates and in their place you can rotate left, rigth, up and >down and then move forward. > >With the up and down it is even supporting pitch so you can set the robot >position as 0 x coord, 0 z coord, 0 altitude, 0 yaw and 45 pitch. Now if you >call the forward method the avatar will ascend into the sky at a 45 degree >angle for the distance specified. > >It makes it very easy to do things like move the robot round in circles: > > for (int a = 0; a < 24;a++) { > > rotate_left(15); // 15 degrees > forward(1); // 1 meter > } > >I standardized all the units to degrees and meters so there are no ugle >translations anywhere. > >Here is the web page where you can download it from: > >http://members.xoom.com/esumerfd/ActiveWorlds/AWSDK.htm > >I have split the source and binaries up since the total download was getting >a little large. > >The next steps are: > >1. Add guesture support to the movement class. >2. Add more functionality to the avatar_add callback so you get more >informtation about the avatar added. >3. Look at building a Movement derivitive that works in conjunction with >avatar_add and allows a robot to see someone and run away. > >Every day, in every way, I get closer to my field of deer. Though I guess I >am going to be limited to 3 to begin with. Doh. Maybe thats a herdette of >deer. > >Edward Sumerfield. > > > > ## canopusOct 25, 1998, 11:16pm
Thanks for the C++ code, especially the movement classes. Like Walter Knupe, I
was scrambling to learn trigonometry all over again, though I my goal was to have a builder bot that can extend property that is at an arbitary yaw, and though I program in Object Pascal. The process is a lot easier when someone else has already figured it out, even in another language! :) I wonder if the AW SDK could provide support functions in this area; it's surely a basic part of the AW code, and support functions would save everybody from having to program it into their bot code. One support function ought to let us convert a pair of X, Z coords, a distance travelled, and the Yaw of the object, into the X, Z coords of the object's destination. A second support function ought to let us rotate objects around a pivot point, by converting the X, Z coords of the pivot point, the distance of an object from the pivot point, and the degrees in the rotation, into the X, Z coords (and Yaw) of the object after it has travelled its arc. Otherwise, we're all going to spend a lot of time individually reviewing old math textbooks! [View Quote] > This is version 0.2 of the C++ wrapper for the Active Worlds SDK. > > The coolest change is the movement classes. I have removed the need to use > x,y and z coordinates and in their place you can rotate left, rigth, up and > down and then move forward. > > With the up and down it is even supporting pitch so you can set the robot > position as 0 x coord, 0 z coord, 0 altitude, 0 yaw and 45 pitch. Now if you > call the forward method the avatar will ascend into the sky at a 45 degree > angle for the distance specified. > > It makes it very easy to do things like move the robot round in circles: > > for (int a = 0; a < 24;a++) { > > rotate_left(15); // 15 degrees > forward(1); // 1 meter > } > > I standardized all the units to degrees and meters so there are no ugle > translations anywhere. > > Here is the web page where you can download it from: > > http://members.xoom.com/esumerfd/ActiveWorlds/AWSDK.htm > > I have split the source and binaries up since the total download was getting > a little large. > > The next steps are: > > 1. Add guesture support to the movement class. > 2. Add more functionality to the avatar_add callback so you get more > informtation about the avatar added. > 3. Look at building a Movement derivitive that works in conjunction with > avatar_add and allows a robot to see someone and run away. > > Every day, in every way, I get closer to my field of deer. Though I guess I > am going to be limited to 3 to begin with. Doh. Maybe thats a herdette of > deer. > > Edward Sumerfield. ## edward sumerfieldOct 26, 1998, 2:02am
I agree that the SDK should be enhanced with this kind of stuff, but I would
like to see it migrated to an OO solution if possible. It is so much easier to program in that environment. Early days yet though, Roland is just stabalizing the current SDK at the moment. It may be a while before these kind of extensions are released. If we can come up with a list of algorithms that can be implemented maybe we should dedicate a web page to it. Edward Sumerfield. [View Quote] ## roland vilettOct 26, 1998, 5:48pm
Yes the plan has always been to first release an API to the basic
client/server protocol as it currently exists, since that implementation can be completed in the least amount of time and it is the minimal implementation required to provide full bot functionality. In the future, after the initial release and as the SDK matures, "higher level" APIs will be added to encapsulate some of the more complex SDK operations, such as avatar movement, property, etc. -Roland [View Quote] ## canopusOct 28, 1998, 12:48pm
Have you thought about using trig functions for the full 360 degrees? In
Movement.C, you give an example of an avatar which is going to travel 10 meters while facing 5 degrees east of N. Your system calculates 10*sin(5) = 10*.08716 for the change in the avatar's X coord, and 10*cos(5) = 10*.99619 for the change in the avatar's Z coord. If I understand correctly, a 360-degree approach would integrate better into the AW system coords, which use signed values. You can use the Avatar's Yaw as is, 355 degrees. Calculate the avatar's X and Z coords based on the 355 degree angle: 10*sin(355) = 10*-.08716, and 10*cos(355) = 10*+.99619. This is nice, because adding -.08716 puts the avatar further east in the AW system, and adding +.99619 puts the avatar further north in the AW system.In the NW quadrant (0-90 degrees), sin and cos are positive; in the SW quadrant, sin is positive and cos negative; in the SE quadrant, sin and cos are negative; in the NE quadrant, sin is negative and cos is positive. I think most built-in trig functions will give ratios for the full 360 degrees. [View Quote] > I agree that the SDK should be enhanced with this kind of stuff, but I would > like to see it migrated to an OO solution if possible. It is so much easier > to program in that environment. > > Early days yet though, Roland is just stabalizing the current SDK at the > moment. It may be a while before these kind of extensions are released. > > If we can come up with a list of algorithms that can be implemented maybe we > should dedicate a web page to it. > > Edward Sumerfield. > [View Quote] ## canopusOct 28, 1998, 1:01pm
Or maybe that is what Movement.C is doing already, and I've misinterpreted your
diagram, which seems to show the avatar moving NE at an angle of 5 degrees. [View Quote] > Have you thought about using trig functions for the full 360 degrees? In > Movement.C, you give an example of an avatar which is going to travel 10 meters > while facing 5 degrees east of N. Your system calculates 10*sin(5) = 10*.08716 > for the change in the avatar's X coord, and 10*cos(5) = 10*.99619 for the change > in the avatar's Z coord. If I understand correctly, a 360-degree approach would > integrate better into the AW system coords, which use signed values. > You can use the Avatar's Yaw as is, 355 degrees. Calculate the avatar's X and > Z coords based on the 355 degree angle: 10*sin(355) = 10*-.08716, and > 10*cos(355) = 10*+.99619. This is nice, because adding -.08716 puts the avatar > further east in the AW system, and adding +.99619 puts the avatar further north > in the AW system.In the NW quadrant (0-90 degrees), sin and cos are positive; in > the SW quadrant, sin is positive and cos negative; in the SE quadrant, sin and > cos are negative; in the NE quadrant, sin is negative and cos is positive. I > think most built-in trig functions will give ratios for the full 360 degrees. > [View Quote] ## edward sumerfieldOct 29, 1998, 3:52am
I am not sure if this is a problem.
It does take 360 degrees into account. Any angle from 0 to 360 is allowed. The various angles of the circle returning numbers from -1 to 1 as you pointed out. This times the distance gives an appropriate delta. However, I did all my testing at 100n 100w quadrant of the world so I don't know if it would work in the SE for example where the x, z coords are -10000, -10000. It would seem like it would work just be cause the axis are going in the same direction. That is, there is no reversal of direction around zero it just goes negative. I store everything as int but interface with float to achieve the approprate units and each of these can handle the -32767 that is required in a AW world. I guess I will have to test it. Thanks for the hint. Edward Sumerfield [View Quote] > Or maybe that is what Movement.C is doing already, and I've misinterpreted your > diagram, which seems to show the avatar moving NE at an angle of 5 degrees. > [View Quote] ## canopusOct 29, 1998, 7:54pm
Yes, I can now see that your code does allow for all angles, and is certainly the model
for the rest of us to follow. I think it should work in any world quadrant, too; I was trying to picture the avatar as the center of a circle with four quadrants. I noticed that AW yaw places the first quadrant on the NW of the avatar, which is different from standard trig, but blends well with AW practice making S and E negative directions. I want my builder bot to be able to rotate an entire building (including landscape, etc.) to suit the needs of a particular site, working from a standard blueprint. I was trying to relate my trig problem to your avatar solution. Instead of one avatar, it's like I'm choreographing a lot of avatars, who are all moving 5 degrees around concentric circles at various distances from the center of the dance performance. Each avatar has its own n-meter hypotenuse from the center; the problem is working out the sines and cosines for their initial (blueprint) positions and final (constructed) positions. I'll try to post the code as soon as I have a version that works. [View Quote] > I am not sure if this is a problem. > > It does take 360 degrees into account. Any angle from 0 to 360 is allowed. The various > angles of the circle returning numbers from -1 to 1 as you pointed out. This times the > distance gives an appropriate delta. > > However, I did all my testing at 100n 100w quadrant of the world so I don't know if it > would work in the SE for example where the x, z coords are -10000, -10000. It would > seem like it would work just be cause the axis are going in the same direction. That > is, there is no reversal of direction around zero it just goes negative. I store > everything as int but interface with float to achieve the approprate units and each of > these can handle the -32767 that is required in a AW world. > > I guess I will have to test it. Thanks for the hint. > > Edward Sumerfield > [View Quote] ## edward sumerfieldOct 30, 1998, 3:05am
Don't you just have to manipulate the results of the aw_query? It returns the objects in a
zone. Once retrieved, you can then decide on a center, select the objects and sequence through each of them applying the same rotation algorithm. I am not sure how you want to select your objects. Maybe by owner id, or specify some kind of bounding box? The algorithm you want is more complicated than mine. You don't want to work out the yaw of the object as a tangent to your circle, that would get you into differentiation - hated that in school. Given an objects position, a center and an angle of rotation you can work out the new x,z coords. Lets see, if you look at the problem as "how do I move to the edge of my circle at a specified angle" then you have a simple forward movement from circle center algorithm. All you have got to start with is the circle_x , circle_z and object_x, object_z numbers. You have to work out the radius of the circle you want your object to scribe. I think this is the hardest part of all this. First work out the length of the sides of the triangle. delta_x = circle_x - object_x; delta_z = circle_z - object_z; Now work out the angle represented by the object and the circle center. Remember that all these angle things are in radians. This goes back to the tan(angle) = o/h equation so the angle = inverse tan(o/h). angle = atan(delta_x / delta_z); or = atan2(delta_x, delta_z); So the radius is radius = delta_z / cos(angle); Now to work out the position on the edge of the circle for any angle is simple. center_x = 100; center_z = 100; angle = 15; edge_x = center_x + (radius * sin(angle)); edge_z = center_z + (radius * cos(angle)); Move object to edge_x, edge_z; You could get fancy if you want to tilt your circle into the y plane. angle_yaw = 0; angle_pitch = 0; edge_x = center_x + (radius * sin(angle_yaw)); edge_z = center_z + (radius * cos(angle_yaw)); edge_y = center_y + (radius * sin(angle_pitch)); Move object to edge_x, edge_z, edge_y; We are using a constant radius here but what if you wanted to rotate in an ellipse. I guess the radius would have to change with some function of the angle. Maybe you could set the radius for each step using radius = minimum_radius + (radius_variation * cos(angle)); That way your radius would vary from the minimum_radius to the maximum radius (minimum + variation) based on the angle. There is more. We currently have an ellipse whose minimum and maximum dimensions are aligned with the NS and EW axis. You can now rotate your ellipse in the horizontal or vertical plane by adding an angle constant to the radius calculation. radius = minimum_radius + (radius_variation * cos(angle + (ANGLE%360))); You are also going to have to change the yaw of your objects based on how far around the circle they have moved but I think that's just a matter of adding the angle of rotation to the objects yaw. Of coarse, this is a total guess. Its has been years since I played with math's. Its quite fun to get back into it again. I was working with my 15 year old son doing algebra the other day. It takes a while for it all to come back, he is still faster at it than I am. Edward Sumerfield. [View Quote] > Yes, I can now see that your code does allow for all angles, and is certainly the model > for the rest of us to follow. I think it should work in any world quadrant, too; I was > trying to picture the avatar as the center of a circle with four quadrants. I noticed that > AW yaw places the first quadrant on the NW of the avatar, which is different from standard > trig, but blends well with AW practice making S and E negative directions. > I want my builder bot to be able to rotate an entire building (including landscape, etc.) > to suit the needs of a particular site, working from a standard blueprint. I was trying to > relate my trig problem to your avatar solution. Instead of one avatar, it's like I'm > choreographing a lot of avatars, who are all moving 5 degrees around concentric circles at > various distances from the center of the dance performance. Each avatar has its own > n-meter hypotenuse from the center; the problem is working out the sines and cosines for > their initial (blueprint) positions and final (constructed) positions. I'll try to post > the code as soon as I have a version that works. > [View Quote] ## canopusOct 30, 1998, 1:58pm
Yes, my construction bots (mover bot, builder bot, surveyor bot, demolition bot) either record
or manipulate the result of aw_query; the survey record is in an editable form. (See the Delphi news above.) What I am testing corresponds to most of your proposal (not the wildly wonderful elliptical stuff, though!), except that I get the radius for each object (hypotenuse) by geometric means (courtesy of Pythagoras) and calculate the effect of the universal rotation starting from the object's arctan angle. Once the radius and angle of the rotated object location are known, the problem becomes a variant of the moving avatar problem (the radius is the distance moved, the deltax/z are derived by sine and cosine from the rotated angle). There is one aspect of the moving avatar problem that becomes clearer in view of this solution, however: in Movement.C, the negative and positive values returned by sine/cosine are correctly interpreted for AW because Movement.C equates the avatar's angle of motion with the avatar's yaw (which in AW is always calculated conterclockwise from N). To allow the avatar to move backwards, or sideways, while continuing to face the old way, one would have to declare a separate angle of motion, being careful to calculate it in AW fashion, with the first quadrant starting at due N. You yourself notice that the object's yaw rotates as it takes the desired path around the circle (the angle of rotation), not according to the angle of the radius where the object is built (the avatar's angle of motion). I heartily agree: math was fascinating in school, but never so much fun! [View Quote] > Don't you just have to manipulate the results of the aw_query? It returns the objects in a > zone. Once retrieved, you can then decide on a center, select the objects and sequence through > each of them applying the same rotation algorithm. > > I am not sure how you want to select your objects. Maybe by owner id, or specify some kind of > bounding box? > > The algorithm you want is more complicated than mine. You don't want to work out the yaw of > the object as a tangent to your circle, that would get you into differentiation - hated that > in school. Given an objects position, a center and an angle of rotation you can work out the > new x,z coords. > > Lets see, if you look at the problem as "how do I move to the edge of my circle at a specified > angle" then you have a simple forward movement from circle center algorithm. > > All you have got to start with is the circle_x , circle_z and object_x, object_z numbers. You > have to work out the radius of the circle you want your object to scribe. I think this is the > hardest part of all this. > > First work out the length of the sides of the triangle. > > delta_x = circle_x - object_x; > delta_z = circle_z - object_z; > > Now work out the angle represented by the object and the circle center. Remember that all > these angle things are in radians. This goes back to the tan(angle) = o/h equation so the > angle = inverse tan(o/h). > > angle = atan(delta_x / delta_z); or = atan2(delta_x, delta_z); > > So the radius is > > radius = delta_z / cos(angle); > > Now to work out the position on the edge of the circle for any angle is simple. > > center_x = 100; > center_z = 100; > angle = 15; > > edge_x = center_x + (radius * sin(angle)); > edge_z = center_z + (radius * cos(angle)); > Move object to edge_x, edge_z; > > You could get fancy if you want to tilt your circle into the y plane. > > angle_yaw = 0; > angle_pitch = 0; > > edge_x = center_x + (radius * sin(angle_yaw)); > edge_z = center_z + (radius * cos(angle_yaw)); > edge_y = center_y + (radius * sin(angle_pitch)); > Move object to edge_x, edge_z, edge_y; > > We are using a constant radius here but what if you wanted to rotate in an ellipse. I guess > the radius would have to change with some function of the angle. Maybe you could set the > radius for each step using > > radius = minimum_radius + (radius_variation * cos(angle)); > > That way your radius would vary from the minimum_radius to the maximum radius (minimum + > variation) based on the angle. > > There is more. We currently have an ellipse whose minimum and maximum dimensions are aligned > with the NS and EW axis. You can now rotate your ellipse in the horizontal or vertical plane > by adding an angle constant to the radius calculation. > > radius = minimum_radius + (radius_variation * cos(angle + (ANGLE%360))); > > You are also going to have to change the yaw of your objects based on how far around the > circle they have moved but I think that's just a matter of adding the angle of rotation to the > objects yaw. > > Of coarse, this is a total guess. Its has been years since I played with math's. Its quite fun > to get back into it again. I was working with my 15 year old son doing algebra the other day. > It takes a while for it all to come back, he is still faster at it than I am. > > Edward Sumerfield. > [View Quote] ## edward sumerfieldOct 30, 1998, 5:22pm
--------------A0F028B5D7500CF79F42F557
Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit [View Quote] > except that I get the radius for each object (hypotenuse) by geometric > means (courtesy of Pythagoras) Of coarse, good old Pythag' I forgot about him. Now that is h squared = opposite square + adjacent squared right? So your radius is root of opposite squared plus adjacent squared. > and calculate the effect of the universal rotation starting from > the object's arctan angle. I don't get this. You are using the arctan of opposite / adjacent to get what? Which hypotenuse? There is one from the center of the circle to the edge of the circle and one that connects two points on the edge of the circle, from and to x,z locations. I feel a picture coming on. I see you are running Mozilla 4.05 so should be able to see it as well. [Image] Do you mean h1 or h2 assuming the avatar direction follows the yellow arrow? > To allow the avatar to move backwards, > or sideways, while continuing to face the old way, one would have to declare a separate angle of > motion, I think I will add methods for move_right, move_left, move_up and move_down. All retaining the same yaw. I have decided to extrapolate movement patterns from the Movement class. So I will have a Shape class that can have inherited shapes like circle, polygon or line even. Each version of the Shape class will take a Position object and through multiple calls to its move method will translate the coordinates within the Position object to the next location all around the edge of the shape. You might end up with the following. Circle c(position, radius, step, start angle); for (int angle = 0; angle < 24; angle++) { c.move() aw_change_state } Edward Sumerfield. > > [View Quote] --------------A0F028B5D7500CF79F42F557 Content-Type: multipart/related; boundary="------------EDCD693794457AFB4845B423" --------------EDCD693794457AFB4845B423 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> [View Quote] --------------EDCD693794457AFB4845B423 Content-Type: image/gif Content-ID: <part1.363A1200.F3857832 at poboxes.com> Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="C:\TEMP\nsmailQC.gif" R0lGODlhZABQAPcAAAAAAAAAUhAYxhAhzhgxzhg5zhhC1hhS1iFa3iFj3iFr3iGM5ykhximU 7ymc7yml7ym19yn/GDHG9zHO/zHe/zkpzkpCzlJK1mtj1nNr3oyE3pSM58YpMcbG7+fn9+/v //f3c/8xAP////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /////////////////////////////////ywAAAAAZABQAAAI/gBFCBxIsGBBChQmIEy4UCFC hwwfNpwosWLEixAzUsS4UaHBjx8jarQ4kiPJjihPqjRJAaTLgQtTsixJU2bNlTVfupQIcabN nziB+kSoE+TFozeHKk3KFGXRkCebBp26VCjEpwZZUpVadetPrAejWh3rtexFsAS1dl3Lte1E tDDFmnU7VyhcgWrpsiVb9a6IlHoD873pd29dqgAARIgwuKHfv4Yja0xMWTFjwS0LNz5MoXJl hIs3J3yMVHRNz5QrTgiNmbRFyRtRJ1a90LJp0g4VYmYoGwDtmAptt9Yck3Pv3xMdJg7NeQJu hj2bHhdZXHd136w3u64OPLZs5Dy5/gfHzrj547/Ww0ucnlu8+5i+KSyOTvY8d/jfqXfvCd29 79Xl0beVfel1ll97+72XHH6gXfaaVOdBxt5r/SVoYXLxAUiRgDM9NuFRFS54oXoGLpTdhYT5 BUAILIIXIokwvsibRMzJyNR5LLa4kog8xpjebA7NV5x+PuGYo0oF9mgjiBPE9xBzBXJlJAU6 apWkj0zy9p+JDjY25ZFAXbkkf07qVmNJShn515FJKaikbkDGdKKVTj3GImRg1hRljC86GdGZ MrGkJp4hdEfhoXyOx5GQgBVpZwh4KdSinhztGWKTG8kXoKGlWTQooYWqhSh/E8XJ04kcppqZ X3dGSmWV/hrtKStGfvYEaKe4fgrZq6GOOiSI622Z3JwI7ujRowdJWih9s8Z6Ua3F3cpje1ch m9ZCOpLq65DBVZoQsVk+uOpdraalbK/WMeutcmUOKS1yJemKF7awcnrfdWJp6OyA1oqwQQau OsDBpBv252xwASDQkAQKLMBlpl192oEFMEmQgAL1IgpsZw8UEBECDzCgQIPq8ssqpAJNTNAE Coxc5boJNglAxwtJoJADHmsILIT9TqxBBR781TKvom7sW8cKMGAzQg6MrCl1qpIkcQUiaKCB QEMTbdLBJYZMQdYTFCBBg5lGHZHEFFstkAZOa731r/HRnHUDEDzZpbc4oV31/tV7RwRmUIpO IPfIEDRAgQRjS8tfiicPpAEDHmBggQceXHCBB34vyymZCykggAQHFBByAQUQQPLmS8m7E0PZ oi5zXnaLi3pFqq/uNoedlf0aqih2VPtO505bIpoa3UpqiiCQizJY9Goem6GW6uvejSKAkDxa 5TKvbNmmys4QoNoybj32y8OF0MsQtUv8w4t7nxFB42OVvfls8iRsoAqBX3BKBV3/1Pz0e1mJ 4EWSOSFpc/3zn04AGEDNYUopF9HfASlikPgtsHxTQshshPK9CBwPYlH6iAVdwsCTJSRDs8MI lHB1JYeAZIQfyZEMZ0jDGtZQfY0iG+7ad5YXXtCGkUAMIosWQ8QiGvGIRUTJvjDiEhhG6CmW QaIUj4grCo3kJU584ksAkJW1yIVE78OiArX4HMAd6oO008kYyUigQAlvT2DJIhvLiDciAccv cpwjG+2lx+pdL499DOQcxwdIQRryickr5CEXeRfrKZKRkMSKIyNJSTw68pGVzKRALolJTXry k6AMpShHScpSmlInAQEAOw== --------------EDCD693794457AFB4845B423-- --------------A0F028B5D7500CF79F42F557-- ## canopusOct 31, 1998, 1:02am
--------------5E28ECA0E8C29429ABCEF137
Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Nothing special about the arctan business (= your atan2(delta_x, delta_z) ): it should yield the angle at the original object, just above the unlabelled radius on your cool colored diagram. To that angle, I add the user's selected rotation (in degrees). Which allows me to find out what the width of the angle above radius h2 is. On your diagram, the original angle looks like 100 degrees, the rotation like 65 degrees, and the angle of the object to be built looks like 165 degrees. Since it is 165 degrees, and the radius h2 is known, I can proceed to use the avatar solution of sine/cosine routes to the new x and z. Neither the yellow triangle nor the red triangle come into it at all. Of course, I've been so busy reading everybody's fascinating new bot and geometry ideas, that I still haven't tested this out! [View Quote] [View Quote] --------------5E28ECA0E8C29429ABCEF137 Content-Type: multipart/related; boundary="------------72685A34110E35700D520F51" --------------72685A34110E35700D520F51 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <HTML> Nothing special about the arctan business (= your atan2(delta_x, delta_z) ): it should yield the angle at the original object, just above the unlabelled radius on your cool colored diagram. To that angle, I add the user's selected rotation (in degrees). Which allows me to find out what the width of the angle above radius h2 is. On your diagram, the original angle looks like 100 degrees, the rotation like 65 degrees, and the angle of the object to be built looks like 165 degrees. Since it is 165 degrees, and the radius h2 is known, I can proceed to use the avatar solution of sine/cosine routes to the new x and z. Neither the yellow triangle nor the red triangle come into it at all. Of course, I've been so busy reading everybody's fascinating new bot and geometry ideas, that I still haven't tested this out! [View Quote] <P><IMG SRC="cid:part1.363A7DBA.DE282070 at ix.netcom.com" HEIGHT=80 WIDTH=100> <P>Do you mean h1 or h2 assuming the avatar direction follows the yellow arrow? <BLOCKQUOTE TYPE=CITE>To allow the avatar to move backwards, <BR>or sideways, while continuing to face the old way, one would have to declare a separate angle of <BR>motion,</BLOCKQUOTE> I think I will add methods for move_right, move_left, move_up and move_down. All retaining the same yaw. <P>I have decided to extrapolate movement patterns from the Movement class. So I will have a Shape class that can have inherited shapes like circle, polygon or line even. Each version of the Shape class will take a Position object and through multiple calls to its move method will translate the coordinates within the Position object to the next location all around the edge of the shape. <P>You might end up with the following. <P> Circle c(position, radius, step, start angle); <BR> for (int angle = 0; angle < 24; angle++) { <BR> c.move() <BR> aw_change_state <BR> } <P>Edward Sumerfield. <BLOCKQUOTE TYPE=CITE> [View Quote] <P>> Don't you just have to manipulate the results of the aw_query? It returns the objects in a <BR>> zone. Once retrieved, you can then decide on a center, select the objects and sequence through <BR>> each of them applying the same rotation algorithm. <BR>> <BR>> I am not sure how you want to select your objects. Maybe by owner id, or specify some kind of <BR>> bounding box? <BR>> <BR>> The algorithm you want is more complicated than mine. You don't want to work out the yaw of <BR>> the object as a tangent to your circle, that would get you into differentiation - hated that <BR>> in school. Given an objects position, a center and an angle of rotation you can work out the <BR>> new x,z coords. <BR>> <BR>> Lets see, if you look at the problem as "how do I move to the edge of my circle at a specified <BR>> angle" then you have a simple forward movement from circle center algorithm. <BR>> <BR>> All you have got to start with is the circle_x , circle_z and object_x, object_z numbers. You <BR>> have to work out the radius of the circle you want your object to scribe. I think this is the <BR>> hardest part of all this. <BR>> <BR>> First work out the length of the sides of the triangle. <BR>> <BR>> delta_x = circle_x - object_x; <BR>> delta_z = circle_z - object_z; <BR>> <BR>> Now work out the angle represented by the object and the circle center. Remember that all <BR>> these angle things are in radians. This goes back to the tan(angle) = o/h equation so the <BR>> angle = inverse tan(o/h). <BR>> <BR>> angle = atan(delta_x / delta_z); or = atan2(delta_x, delta_z); <BR>> <BR>> So the radius is <BR>> <BR>> radius = delta_z / cos(angle); <BR>> <BR>> Now to work out the position on the edge of the circle for any angle is simple. <BR>> <BR>> center_x = 100; <BR>> center_z = 100; <BR>> angle = 15; <BR>> <BR>> edge_x = center_x + (radius * sin(angle)); <BR>> edge_z = center_z + (radius * cos(angle)); <BR>> Move object to edge_x, edge_z; <BR>> <BR>> You could get fancy if you want to tilt your circle into the y plane. <BR>> <BR>> angle_yaw = 0; <BR>> angle_pitch = 0; <BR>> <BR>> edge_x = center_x + (radius * sin(angle_yaw)); <BR>> edge_z = center_z + (radius * cos(angle_yaw)); <BR>> edge_y = center_y + (radius * sin(angle_pitch)); <BR>> Move object to edge_x, edge_z, edge_y; <BR>> <BR>> We are using a constant radius here but what if you wanted to rotate in an ellipse. I guess <BR>> the radius would have to change with some function of the angle. Maybe you could set the <BR>> radius for each step using <BR>> <BR>> radius = minimum_radius + (radius_variation * cos(angle)); <BR>> <BR>> That way your radius would vary from the minimum_radius to the maximum radius (minimum + <BR>> variation) based on the angle. <BR>> <BR>> There is more. We currently have an ellipse whose minimum and maximum dimensions are aligned <BR>> with the NS and EW axis. You can now rotate your ellipse in the horizontal or vertical plane <BR>> by adding an angle constant to the radius calculation. <BR>> <BR>> radius = minimum_radius + (radius_variation * cos(angle + (ANGLE%360))); <BR>> <BR>> You are also going to have to change the yaw of your objects based on how far around the <BR>> circle they have moved but I think that's just a matter of adding the angle of rotation to the <BR>> objects yaw. <BR>> <BR>> Of coarse, this is a total guess. Its has been years since I played with math's. Its quite fun <BR>> to get back into it again. I was working with my 15 year old son doing algebra the other day. <BR>> It takes a while for it all to come back, he is still faster at it than I am. <BR>> <BR>> Edward Sumerfield. <BR>> [View Quote] --------------72685A34110E35700D520F51 Content-Type: image/gif Content-ID: <part1.363A7DBA.DE282070 at ix.netcom.com> Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="C:\TEMP\nsmailQC.gif" R0lGODlhZABQAPcAAAAAAAAAUhAYxhAhzhgxzhg5zhhC1hhS1iFa3iFj3iFr3iGM5ykhximU 7ymc7yml7ym19yn/GDHG9zHO/zHe/zkpzkpCzlJK1mtj1nNr3oyE3pSM58YpMcbG7+fn9+/v //f3c/8xAP////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /////////////////////////////////ywAAAAAZABQAAAI/gBFCBxIsGBBChQmIEy4UCFC hwwfNpwosWLEixAzUsS4UaHBjx8jarQ4kiPJjihPqjRJAaTLgQtTsixJU2bNlTVfupQIcabN nziB+kSoE+TFozeHKk3KFGXRkCebBp26VCjEpwZZUpVadetPrAejWh3rtexFsAS1dl3Lte1E tDDFmnU7VyhcgWrpsiVb9a6IlHoD873pd29dqgAARIgwuKHfv4Yja0xMWTFjwS0LNz5MoXJl hIs3J3yMVHRNz5QrTgiNmbRFyRtRJ1a90LJp0g4VYmYoGwDtmAptt9Yck3Pv3xMdJg7NeQJu hj2bHhdZXHd136w3u64OPLZs5Dy5/gfHzrj547/Ww0ucnlu8+5i+KSyOTvY8d/jfqXfvCd29 79Xl0beVfel1ll97+72XHH6gXfaaVOdBxt5r/SVoYXLxAUiRgDM9NuFRFS54oXoGLpTdhYT5 BUAILIIXIokwvsibRMzJyNR5LLa4kog8xpjebA7NV5x+PuGYo0oF9mgjiBPE9xBzBXJlJAU6 apWkj0zy9p+JDjY25ZFAXbkkf07qVmNJShn515FJKaikbkDGdKKVTj3GImRg1hRljC86GdGZ MrGkJp4hdEfhoXyOx5GQgBVpZwh4KdSinhztGWKTG8kXoKGlWTQooYWqhSh/E8XJ04kcppqZ X3dGSmWV/hrtKStGfvYEaKe4fgrZq6GOOiSI622Z3JwI7ujRowdJWih9s8Z6Ua3F3cpje1ch m9ZCOpLq65DBVZoQsVk+uOpdraalbK/WMeutcmUOKS1yJemKF7awcnrfdWJp6OyA1oqwQQau OsDBpBv252xwASDQkAQKLMBlpl192oEFMEmQgAL1IgpsZw8UEBECDzCgQIPq8ssqpAJNTNAE Coxc5boJNglAxwtJoJADHmsILIT9TqxBBR781TKvom7sW8cKMGAzQg6MrCl1qpIkcQUiaKCB QEMTbdLBJYZMQdYTFCBBg5lGHZHEFFstkAZOa731r/HRnHUDEDzZpbc4oV31/tV7RwRmUIpO IPfIEDRAgQRjS8tfiicPpAEDHmBggQceXHCBB34vyymZCykggAQHFBByAQUQQPLmS8m7E0PZ oi5zXnaLi3pFqq/uNoedlf0aqih2VPtO505bIpoa3UpqiiCQizJY9Goem6GW6uvejSKAkDxa 5TKvbNmmys4QoNoybj32y8OF0MsQtUv8w4t7nxFB42OVvfls8iRsoAqBX3BKBV3/1Pz0e1mJ 4EWSOSFpc/3zn04AGEDNYUopF9HfASlikPgtsHxTQshshPK9CBwPYlH6iAVdwsCTJSRDs8MI lHB1JYeAZIQfyZEMZ0jDGtZQfY0iG+7ad5YXXtCGkUAMIosWQ8QiGvGIRUTJvjDiEhhG6CmW QaIUj4grCo3kJU584ksAkJW1yIVE78OiArX4HMAd6oO008kYyUigQAlvT2DJIhvLiDciAccv cpwjG+2lx+pdL499DOQcxwdIQRryickr5CEXeRfrKZKRkMSKIyNJSTw68pGVzKRALolJTXry k6AMpShHScpSmlInAQEAOw== --------------72685A34110E35700D520F51-- --------------5E28ECA0E8C29429ABCEF137-- ## canopusOct 31, 1998, 1:48am
Just tested out the code for a builder bot modified to build a blueprint
with a rotation, if requested. Seemed to work. You can check the results at 8s 93w on Beta, where there is a simple building to your south that was moved by a mover bot to that location, and the same building design, rotated 180 degrees, on your north, built by the revised builder bot. (Also, further to the south, there is an empty space where there used to be a huge building that was cleanly and neatly demolished by a demolition bot, without touching the neighboring property.) While I was there, I got some neighborly advice that matrix math was a good way to do rotations. [View Quote] [View Quote] ## edward sumerfieldOct 31, 1998, 1:58am
--------------0434EC37DB3981F43E4B7FA9
Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Ok, I think I understand. The only thing I am concerned about is that you have x/z which would give you the angle at the center of the circle. You want z/x to give you the angle that the object has to more forward at. Its hard to communicate this stuff this way. Just make it happen dude, I want to see spinning buildings. [View Quote] > Nothing special about the arctan business (= your atan2(delta_x, delta_z) > ): it should yield the angle at the original object, just above the > unlabelled radius on your cool colored diagram. To that angle, I add the > user's selected rotation (in degrees). Which allows me to find out what the > width of the angle above radius h2 is. On your diagram, the original angle > looks like 100 degrees, the rotation like 65 degrees, and the angle of the > object to be built looks like 165 degrees. Since it is 165 degrees, and the > radius h2 is known, I can proceed to use the avatar solution of sine/cosine > routes to the new x and z. Neither the yellow triangle nor the red triangle > come into it at all. Of course, I've been so busy reading everybody's > fascinating new bot and geometry ideas, that I still haven't tested this > out! > [View Quote] --------------0434EC37DB3981F43E4B7FA9 Content-Type: multipart/related; boundary="------------28C2B9174F3EF31CF54BEF48" --------------28C2B9174F3EF31CF54BEF48 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> Ok, I think I understand. The only thing I am concerned about is that you have x/z which would give you the angle at the center of the circle. You want z/x to give you the angle that the object has to more forward at. <p>Its hard to communicate this stuff this way. Just make it happen dude, I want to see spinning buildings. [View Quote] --------------28C2B9174F3EF31CF54BEF48 Content-Type: image/gif Content-ID: <part1.363A8AD7.77C2E8E8 at poboxes.com> Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="C:\TEMP\nsmailQC.gif" R0lGODlhZABQAPcAAAAAAAAAUhAYxhAhzhgxzhg5zhhC1hhS1iFa3iFj3iFr3iGM5ykhximU 7ymc7yml7ym19yn/GDHG9zHO/zHe/zkpzkpCzlJK1mtj1nNr3oyE3pSM58YpMcbG7+fn9+/v //f3c/8xAP////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /////////////////////////////////ywAAAAAZABQAAAI/gBFCBxIsGBBChQmIEy4UCFC hwwfNpwosWLEixAzUsS4UaHBjx8jarQ4kiPJjihPqjRJAaTLgQtTsixJU2bNlTVfupQIcabN nziB+kSoE+TFozeHKk3KFGXRkCebBp26VCjEpwZZUpVadetPrAejWh3rtexFsAS1dl3Lte1E tDDFmnU7VyhcgWrpsiVb9a6IlHoD873pd29dqgAARIgwuKHfv4Yja0xMWTFjwS0LNz5MoXJl hIs3J3yMVHRNz5QrTgiNmbRFyRtRJ1a90LJp0g4VYmYoGwDtmAptt9Yck3Pv3xMdJg7NeQJu hj2bHhdZXHd136w3u64OPLZs5Dy5/gfHzrj547/Ww0ucnlu8+5i+KSyOTvY8d/jfqXfvCd29 79Xl0beVfel1ll97+72XHH6gXfaaVOdBxt5r/SVoYXLxAUiRgDM9NuFRFS54oXoGLpTdhYT5 BUAILIIXIokwvsibRMzJyNR5LLa4kog8xpjebA7NV5x+PuGYo0oF9mgjiBPE9xBzBXJlJAU6 apWkj0zy9p+JDjY25ZFAXbkkf07qVmNJShn515FJKaikbkDGdKKVTj3GImRg1hRljC86GdGZ MrGkJp4hdEfhoXyOx5GQgBVpZwh4KdSinhztGWKTG8kXoKGlWTQooYWqhSh/E8XJ04kcppqZ X3dGSmWV/hrtKStGfvYEaKe4fgrZq6GOOiSI622Z3JwI7ujRowdJWih9s8Z6Ua3F3cpje1ch m9ZCOpLq65DBVZoQsVk+uOpdraalbK/WMeutcmUOKS1yJemKF7awcnrfdWJp6OyA1oqwQQau OsDBpBv252xwASDQkAQKLMBlpl192oEFMEmQgAL1IgpsZw8UEBECDzCgQIPq8ssqpAJNTNAE Coxc5boJNglAxwtJoJADHmsILIT9TqxBBR781TKvom7sW8cKMGAzQg6MrCl1qpIkcQUiaKCB QEMTbdLBJYZMQdYTFCBBg5lGHZHEFFstkAZOa731r/HRnHUDEDzZpbc4oV31/tV7RwRmUIpO IPfIEDRAgQRjS8tfiicPpAEDHmBggQceXHCBB34vyymZCykggAQHFBByAQUQQPLmS8m7E0PZ oi5zXnaLi3pFqq/uNoedlf0aqih2VPtO505bIpoa3UpqiiCQizJY9Goem6GW6uvejSKAkDxa 5TKvbNmmys4QoNoybj32y8OF0MsQtUv8w4t7nxFB42OVvfls8iRsoAqBX3BKBV3/1Pz0e1mJ 4EWSOSFpc/3zn04AGEDNYUopF9HfASlikPgtsHxTQshshPK9CBwPYlH6iAVdwsCTJSRDs8MI lHB1JYeAZIQfyZEMZ0jDGtZQfY0iG+7ad5YXXtCGkUAMIosWQ8QiGvGIRUTJvjDiEhhG6CmW QaIUj4grCo3kJU584ksAkJW1yIVE78OiArX4HMAd6oO008kYyUigQAlvT2DJIhvLiDciAccv cpwjG+2lx+pdL499DOQcxwdIQRryickr5CEXeRfrKZKRkMSKIyNJSTw68pGVzKRALolJTXry k6AMpShHScpSmlInAQEAOw== --------------28C2B9174F3EF31CF54BEF48-- --------------0434EC37DB3981F43E4B7FA9-- ## canopusOct 31, 1998, 11:42pm
The builderbot code that takes care of rotating the building objects
goes like this: deltax := objx - builderbotx; deltaz := objz - builderbotz; deltah := Hypot(deltax, deltaz); deltaw := Arctan2(deltax, deltaz) + Rotation; SinCos(deltaw, sinix, cosiz); deltax := sinix * deltah; deltaz := cosiz * deltah; objx := builderbotx + deltax; objz := builderbotz + deltaz; The middle 5 lines of straightforward trigonometry could be replaced by 2 lines of matrix math (thanks to Netropolis for this suggestion): deltaz := (deltaz * Cos(Rotation)) - (deltax * Sin(Rotation)); deltax := (deltaz * Sin(Rotation)) + (deltax * Cos(Rotation)); [View Quote] [View Quote] ## canopusOct 31, 1998, 11:58pm
The matrix math lines should read:
newdeltaz := (deltaz * Cos(Rotation)) - (deltax * Sin(Rotation)); deltax := (deltaz * Sin(Rotation)) + (deltax * Cos(Rotation)); deltaz := newdeltaz; [View Quote] > The builderbot code that takes care of rotating the building objects > goes like this: > deltax := objx - builderbotx; > deltaz := objz - builderbotz; > deltah := Hypot(deltax, deltaz); > deltaw := Arctan2(deltax, deltaz) + Rotation; > SinCos(deltaw, sinix, cosiz); > deltax := sinix * deltah; > deltaz := cosiz * deltah; > objx := builderbotx + deltax; > objz := builderbotz + deltaz; > The middle 5 lines of straightforward trigonometry could be replaced by > 2 lines of matrix math (thanks to Netropolis for this suggestion): > deltaz := (deltaz * Cos(Rotation)) - (deltax * Sin(Rotation)); > deltax := (deltaz * Sin(Rotation)) + (deltax * Cos(Rotation)); > [View Quote] ## edward sumerfieldNov 1, 1998, 2:01pm
Cool stuff, thanks for the tip.
Edward Sumerfield. [View Quote] > The matrix math lines should read: > newdeltaz := (deltaz * Cos(Rotation)) - (deltax * Sin(Rotation)); > deltax := (deltaz * Sin(Rotation)) + (deltax * Cos(Rotation)); > deltaz := newdeltaz; > [View Quote] ## canopusNov 1, 1998, 5:04pm
As well as the above code segment, that rotates the building, there is the
segment (mentioned in earlier discussions) that rotates each object as it moves into its new location further along the circle (objw is the object's yaw). objw := objw + Rotation; This code works for the standard trigonometric version and the compact version taken from matrix math. The matrix math version, by the way, seems to be nothing but the two "addition formulas" of trigonometric analysis, cos(x + y) = (cos x * cos y) - (sin x * sin y) sin(x + y) = (sin x * cos y) + (cos x * sin y) after one has substituted in for the constant radius (hypotenuse) and the known values of the relative coords at angle x (treating the rotation as angle y). [View Quote] > The builderbot code that takes care of rotating the building objects > goes like this: > deltax := objx - builderbotx; > deltaz := objz - builderbotz; > deltah := Hypot(deltax, deltaz); > deltaw := Arctan2(deltax, deltaz) + Rotation; > SinCos(deltaw, sinix, cosiz); > deltax := sinix * deltah; > deltaz := cosiz * deltah; > objx := builderbotx + deltax; > objz := builderbotz + deltaz; > The middle 5 lines of straightforward trigonometry could be replaced by > 2 lines of matrix math (thanks to Netropolis for this suggestion): > deltaz := (deltaz * Cos(Rotation)) - (deltax * Sin(Rotation)); > deltax := (deltaz * Sin(Rotation)) + (deltax * Cos(Rotation)); > [View Quote] ## roland vilettNov 1, 1998, 7:19pm
I just wanted to toss in here something to watch out for. I've probably
mentioned this before, but if you write code that moves entire buildings you have to be prepared to encounter area-full areas if you are moving large numbers of objects in sub-cell increments. The reason for this is that if you have a building that has been built more or less at or close to the cell data limit for that world, it is quite likely that if you move the building so that it no longer contains the same N/S orientation or no longer falls in the same position relative to the cell gridlines, the building's objects will fall into a different arrangement of cells in their new location, causing a re-distribution of object data amongst the cells. As a result, you will probably wind up with one or two objects that can no longer be placed because the cell data limit has been exceeded in the new arrangement. The only way to avoid this problem is to avoid building right up to the cell data limit before moving a building, or to only move buildings in distances of whole cell increments so that the objects retain the identical cell data distribution at their new location. -Roland [View Quote] |

Awportals.com is a privately held community resource website dedicated to Active Worlds.

Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.

Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.