Wind and Rotations

So I must apologize for (A) having gotten distracted from the combat-system scripting by thinking about the details of sailboat physics, and (B) posting some stuff here that is really just for me, but I thought it might someday be useful to someone else to, and besides this was a handy place to jot it down.

There are an annoying number of ways to write down rotations and directions and things in LSL, and different parts of the word want different ones. (And this is just, for the moment, talking about rotations in two dimensions!)

For instance, llWind() returns a vector representing the wind direction. Wind is (I believe!) always flat (parallel to the ground) in SL, so we can ignore Z. But what exactly are X and Y?

Well, Rule 1 (which I always forget and have to try out again) is that X is East and Y is North. So if for instance I am standing at 117, 119, 117 in Hughes Rise, on the walkway in the Park, and I walk one meter due North, I’ll be at 117, 120, 117. See how Y got bigger? And if I walk one meter due West from there, toward the stairs, I’ll be at 116, 120, 117; X got smaller.

So if llWind returns < 5, 0, 0 > for instance, that means the wind is blowing at five meters per second toward the East (and therefore is called a West wind, ’cause winds are called by where they are coming from, just to be confusing).

Now say you have a sail, and you want to know the angle between the sail and the wind. Well, the sail’s trim is represented as a rotation, which can be represented in LSL either as an actual rotation object (which has four components, corresponding to the four components of the corresponding quaternion, where a quaternion is of course an element of a four-dimensional associative normed division algebra over the real numbers), which is mathematically wonderful but not too useful for actually thinking about, or as a three-element vector, each element representing a rotation about the corresponding axis.

So for instance if your sail is flat in the X dimension, it will be facing head-on to winds coming from the east or west. If you then rotate it ninety degrees (which is a rotation of pi/2, or PI_BY_TWO, in radians) about the Z axis (the up-and-down one), it will be facing head-on to winds coming from the north or south.

To represent a rotation of pi/2 radians as a vector in LSL, we write < 0, 0, PI_BY_TWO >. Now the fun part! If I know the X and Y parts of the wind speed from llWind, and I have the rotation of my sail as a rotation about the Z axis, how do I figure out the angle at which the wind is hitting my sail?

Now I pause to think and experiment a little, so as to have an answer to write down in the next paragraphs. :)

Well, first of all notice that by using a symmetrical sail and a rotation of pi/2, I’ve sort of cheated; in particular, I didn’t have to figure out whether rotations are clockwise or counterclockwise (anticlockwise). This is probably obvious to smart people of various kinds, but I can never remember it (some Right Hand Rule or something is probably involved) so I have done the experiment and will write down Rule 2: Rotations are counterclockwise, or, to be precise and therefore meaningful, if you’re looking down at something that is not rotated, and you rotate it positively about the Z axis, it moves around anticlockwise.

This surprised me. :)

It makes sense, though, if we think back to like Trig 101 or whatever that was; X is East (i.e. to the right on the map), and Y is North (upward on the map), which is just how the graphs were all done on the board, and if you start out with a line running from the origin to < 1,0 >, say, and “rotate it” by some small angle theta, it goes up a bit into th’ ol’ First Quadrant there, which means it’s moved anticlockwise.

(Whoever designed clocks must have skipped that class or something.)

So we can represent wind direction as a rotation-about-Z by drawing it on the board there using the X and Y that we got from llWind(), and straightforwardly figure out what angle we would have to rotate that origin-to-1,0 line through to get it there, and it turns out to be (unless I’m wrong) llAtan2(Y,X); that is, the angle whose tangent is y over x.

So we have two rotation amounts, the amount that our sail’s been rotated and the amount that the wind’s been “rotated”, and we can just subtract them from each other to get the angle between them. If they’ve been rotated the same, the difference is zero, and our sail is getting (basically) all of the benefit of the wind. If they are ninety degrees apart, the sail is edge-on to the wind, and getting no benefit at all. Because we suspect there is probably something trigonometric going on here, we will note that llCos(0) is 1.0, and llCos(PI/2) is 0.0, and decide that we can do, say:


vector wind = llWind(ZERO_VECTOR); // The wind right here
float windrotz = llAtan2(wind.y,wind.x);
vector sailrot = llRot2Euler(llGetLocalRot());
float sailrotz = sailrot.z;
float rot_difference = windrotz - sailrotz;
float wind_effect_on_sail = llCos(rot_difference);

and so wind_effect_on_sail will be 1 if the wind’s blowing right onto the sale, will be 0 if the wind is blowing edge-on onto the sail (luffing!), and will be inbetween in between. (It will also be negative, I think, if the wind is blowing on the wrong side of the sail, but I haven’t thought about that yet.)

And some similar calculation can be used to get the angle between the sail and the hull (or, really, the keel), to figure out how much of the wind’s effect on the sail then contributes to the forward motion of the boat. But that’s a little later. :)

A Slip in Eden

I like that title. :) Could be a poem, a novel…

Nice and ambiguous!

In this case, it relates to a slip in the sense of “a docking place for a ship between two piers”.

Slip in Eden

I checked quickly inworld this morning (I’ve been travelling on RL business, and hardly on the net at all), to look at my group notices and such, and because of some random subscribe-o-matic that I’m on, I got a note about land ownership and rental opportunities in the Eden sims, which I remember from some concert or other the other month as being a friendly and clothing-optional place. (Didn’t find a website for them offhand, but here is a lil video.)

I TPd over on a whim and poked around a little, and came to a desert island where I could rez the Twenty and sail about, and eventually I ended up in a sort of downtown waterfront area, and I glided gracefully into a slip.

One of the owners of the place was around, and we talked for awhile, and I ended up renting the slip for a couple of weeks (just some smallish number of L for 30 or so prims right on the pier there; very nice).

Turns out that the Eden sims are a group of ten or so regions contiguous to the Fruit sims, which are a group of even more regions, all of them lovely and watery and perfect for sailing, as well as actively managed by some apparently-clued people.

Eden And Fruit

It’s big, maybe the size of the Blake Sea, and equally sailable, with I think more islands and less plain open water, and therefore more interesting (and a bit more challenging) to sail about in. I did not take a SLURL, but if you search the map for “Eden Naturopolis”, that should

I suspect I will be doing some hanging-about in the area! :) Assuming I get a chance to get inworld more soon. And I don’t get distracted by anything shiny…

Update: Here’s the Eden website.

Nowhereville to Piper Point

I am always gushing about how much I love the mainland for its chaos and randomness, and it’s very true.

On the other hand there’s also alot to be said for beauty and organization, and a place formed through a consistent vision or set of compatible visions. Mostly these are on estates, and mostly they get praised enough already :) which is why I usually spend more of my praise on the neglected mainland. But sometimes…

Nowhereville_001

I was reading a Crap Mariner posting and thinking "whoa, that is a nice-looking place". So I went there and rezzed the Twenty and sailed around on the jib, admiring things.

Here’s the Bridge of Crap’s posting, connecting Nowhereville to Piper Point:

Nowhereville_002

Under the bridge, into the bay:

Nowhereville_003

The waterfalls from above:

Nowhereville_004

And drifting into the bay, past the fishing and lounging area of (I think) the Lonely Yak Roadhouse:

Nowhereville_005

A quiet and soothing place, and a lovely bunch of builds. Order can be just as lovely as chaos, when it’s done well. :)

… And a star to steer her by

One of my very very favorite Solstice-time presents this year was this amazing Tall Ship; the Tradewind from Trudeau Classic Sailing Yachts.

Passing WIndlass, in weather

Bingo Strait, Qomene (120, 90, 22)

Christmas Day Sailing

It’s really an astounding ship, big and grand and detailed and authentic. It has many many prims, and in fact most of the ship is worn as an attachment because of that; the part that you rezz on the water is just a basic (invisible) outline, and the sitting poseballs. (It holds the captain, and I think up to three crew / guests.) It has an optional-rez cabin with a bunk that sleeps two, and you can change the color scheme, authorize other people to sail it, and do lotsa other stuff that I haven’t tried yet.

I liked it so much that when I got some RL cash for Christmas I converted half of it to Lindens, and used a fraction of that to buy a little daysailor from the same place; the Trudeau Twenty. It is an incredibly sweet little boat:

Sea of Tranquility (41, 110, 21)

Here I am moored next to a recreation of a Piranesi drawing:

Mar Menor (159, 8, 21)

(I love Piranesi’s dark fantastic work, but I was having too much fun sailing to stop and give it a thorough lookover; will have to go back there sometime.)

A wonderful feature of the Twenty is the boom tent. You can drop anchor and rez the boom tent, which includes a mattress with sleeping poesballs, for a nap or an overnight:

Boom Tent, Nautilus Harbor Rez Zone, Nautilus - Yamm

It’s practically a houseboat! (Now I have to play with the Tall Ship more, and see what surprises it has that I haven’t found yet.)

(Oh, and that’s an automated airship in the background, just pulling in. Have to take that tour sometime, too…)

Wind and Sailing in Second Life

Speaking of sailing in SL, a v good friend suggested that I say a word about how the wind works, for SL-sailing purposes.

The simplest sailboats, like my Skipjack “Indolence”, just go wherever you point them, as fast as you tell them to go; they are actually powerboats with decorative sails, and don’t care about the wind at all.

The Trudeau yachts, on the other hand, use a pretty sophisticated model of sails and wind, and have HUDs that tell you where the wind is coming from, let you raise and lower and take in and let out and reef the sails, and so on, and the behavior of the craft (including really nice water and sail sounds) is directly related to how the sails are set compared to how the wind is blowing. For some value of “wind”.

There are at least three kinds of wind in Second Life that a sailboat can use: the “built-in” SL wind that scripts can detect, a custom wind as specified by the sailor (it’s really nice, if you don’t want to tack painfully upwind in a narrow channel for hours, to just tell the boat “pretend the wind is coming from right behind us”), and “racewind”, which is a shared wind for an area that is broadcast by a scripted object, so that all the race-compatible boats around can see the same wind, and race fairly.

All these kinds of wind are described in more detail on the Wind page of the Second Sailing Wiki, which I recommend to anyone interested in the details.

All of which shouldn’t scare anyone off from SL sailing; it’s not actually hard at all, just lots of fun. I haven’t sailed in RL in years, and even then it was just simple one-sail boats on little lakes; but figuring out the controls on the Trudeau craft didn’t take me long at all (once I figured out which arrow was the wind-direction indicator!), and I’m finding sailing with an actual wind (of whichever kind I’m in the mood for) to be a lovely soothing thing to do.

Try it, if you haven’t! Maybe I’ll see you on th’ waves. :)

Ducking in for a sail

So as previously announced, this week is being RL-crazy and I haven’t been able to spend my usual few hours a day inworld. On the other hand it turns out that SL is very nice in an entirely different mode, consisting of slipping in between crazinesses and just sort of exploring and bumming around.

I mentioned on Twitter or somewhere that I’d travelled by motorcycle randomly from the Manitoba region somewhere (where I’d gotten to by following a LM to the Alice Free Library or something as I vaguely recall), eventually ending up in Mare at the old Elbow Room (entirely by accident). That was in a lull between meetings yesterday or so.

Today in another lull, feeling a bit stressed and without time to do anything really significant between two other things, I ducked inworld again, and having noticed a nice-looking little seaside town in Mowry along the road from Manitoba to Mare, I TPd to somewhere near there and then took my seedpod ship into Mowry.

Turns out there’s a nice little community around the bay in Mowry and adjoining sims (including some very nice-looking treehouse rentals that turn out to be owned by someone that I know in another context entirely, which was funny to see; small second world!). I landed my seedpod ship in the marina, rezzed my current favorite sailboat, and boated about for awhile:

The Good Ship Indolence on Mowry Bay

That’s the Good Ship Indolence in Mowry Bay; click through to flickr for some more random details.

All in all it was a very fun quick visit; it reminded me of how things used to be when I didn’t have as much going on inworld, socially and artistically and professionally, and would just sort of bum around randomly and find stuff. Have to do more of that!