Scripting Angles

Okay all you math wizards out there. It's been a long, long, very long time since I worked with geometry/trig.

Any help is appreciated. Not looking for a specific answer but, some pointers in the right direction.

Below is a picture of what I'm trying to do.

Basically, I want to drop object 2 straight down the y-axis from object 1 (that I can do).

Then arc object 2 (one radian) up towards object 3 on the x-axis.

If I do a tangent formula will that not move the object in essentially a straight line and not an arc?

mathqmq0.jpg

#472029

Looks like you want to move the object along a quarter-circle, then, right? And the radius is the distance between 1 and 3...

I'm not sure exactly what context you're doing this in, but could you use parametric curves?

-NC

#472060

:o Oh no calculus! :D

Never thought of that or bezier curve but, I think that's a little more than I need for this. It's got me thinking of some neat Effectlets for AveDesk.

Yep, the quarter circle or essentially one radian. It should move in the arc pattern since the tangent only intersects at the circle's edge?

What I'm trying to do is the same "fanning" effect that Stardock's latest weather docklet does. The day forecast drops/pops up then fans out over a 180 degree arc.

I've been able to make a script based on the Orbit Effectlet but, just trying to refresh my mind and build one from scratch.

Unfortunately my mind is rustier than a 50 year old nail. ;)

#472069

It probably won't be as smooth as a parametric curve, but can you have it trace out a path along the following equation?

y = - sqrt(r^2 - x^2)

where r is the appropriate radius (distance between 1 and 3), and you pick a suitable x so that it draws in the appropriate fashion. This is assuming the circle is centered at 1, and you're using it as the origin.

-NC

#472122

Interesting. Yes, things will be centered at 1. Give this a better look tomorrow. Thanks.

Found an old Javascript Rotation Tutorial & a 3D Rotation Tutorial for Visual Basic. So, have lot's to go through.

#472125

On a side note:

Mostly it is unnecessary to invent the wheel over and over again.

Just rotate the viewport, draw the object and restore the viewport again.

Whatever praiseworthy graphics library you are using, it should have a function named TransformWorld or suchlike.

hth,

herd

#472145

Ok. You've confused me a bit.

#472280

Please excuse the late answer.

It depends on what graphics library you are programming with:

To accomplish the task from above, move the drawing origin (0,0) to the center of image 1.

move it straight down, draw 2. Rotate the coordinate system around 0,0 counter-clockwise 1°, draw 2 again, erase all, repeat. To the user, it will appear as if 2 is moving slowly to 3, but for you it is just calling a function of your library in a loop.

Chances are good that this kind of 'shifting the paper instead of the pen' goes faster than calculating manually thanks to hardware acceleration.

If your graphics library does not support coordinate transformation, (move, shear, scale, rotate) get a decent one. Whatever the graphics library, these methods are the most required in 2D animation. Their naming may vary. IIRC, even DHTML has them.

hth,

herd

#474117

I'm not going to pretend that I have any actual knowledge of maths, or guarantee that this is what you've searched for,

but here's a (shortened) code snippet I used in a scripting language to get x/y data for positioning buttons in a circular form.

Maybe it's useful for you:

DrawCircle(center_x, center_y, Radius, NumOfItems)
{
Degree = 0
PointSpacing := 360 / NumOfItems

Loop, %NumOfItems%
{
XPos := sin(DegToRad(Degree)) * Radius + center_x
YPos := cos(DegToRad(Degree)) * Radius + center_y

Degree += PointSpacing
}
}

(This'll start the the Circle at 6 o' clock, then proceed clockwise.)

#474137

Herd,

thanks that's a little easier to understand. I or more specifically DesktopX doesn't have a graphics library and I'm trying to do this within script without an external com object. OR at least develop or translate some functions into an external library.

philou, that function will come in handy.

Here's a link to the script I've been playing around with.

http://forums.wincustomize.com/?forumid=16...=152416#1223446

#474138