Thread Tools Display Modes
02-11-14, 04:26 PM   #21
Malsomnus
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2013
Posts: 203
Originally Posted by Duugu View Post
Lets say the values are 14, 6, 340

The intented result for the second degree value would be 357.

Using Resike's code
Lua Code:
  1. degrees[i] = (degrees[i - 1] + degrees[i + 1]) / 2
the value would be

(14 + 340) / 2 = 177
This sort of simple averaging is terrible even if you do solve the angle issue and would warp your data completely...
__________________
SanityCheck - If you've ever said the words "Sorry, I forgot" then you need this add-on.

Remember, every time you post a comment on an add-on, a kitten gets its wings!
  Reply With Quote
02-11-14, 05:49 PM   #22
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Vrul View Post
Based off your intended use your values should not exceed the +/-90 degree range, so if your array contained -7 instead of 353 it would work just fine. That pushes the problem boundary to the 180 degree area where your values should never realistically be. You're not taking full advantage of the available ways to store what you have and are trying to create a needlessly complex system to compensate for it.
Ok. Let me see if I understand what you mean.

Lets assume 14, 6, 340 again.
The calculated value should be 357 .

You are saying I should use 14, 6, -20 instead.
The calculated value should be -3.

Resike's code
Code:
degrees[i] = (degrees[i - 1] + degrees[i + 1]) / 2
translates into
(14 + -20) / 2 = -3
Which is the desired result.

Well. That is simple. Even if it does not use the values I've posted below. Thank you for pushing me into this direction.

Last edited by Duugu : 02-11-14 at 05:55 PM.
  Reply With Quote
02-12-14, 12:18 AM   #23
Malsomnus
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2013
Posts: 203
Originally Posted by Duugu View Post
Ok. Let me see if I understand what you mean.

Lets assume 14, 6, 340 again.
The calculated value should be 357 .

You are saying I should use 14, 6, -20 instead.
The calculated value should be -3.
Suppose the values are 170, 185, 160? Then you turn it into 170, -175, 160, and have the same problem, because circles have no magic spots on them that makes problems go away, on account of being perfectly symmetrical.

/sigh
I gave you working code for a working algorithm, and mentioned an even better algorithm, do with it what you will.
__________________
SanityCheck - If you've ever said the words "Sorry, I forgot" then you need this add-on.

Remember, every time you post a comment on an add-on, a kitten gets its wings!
  Reply With Quote
02-12-14, 12:41 AM   #24
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Malsomnus View Post
/sigh
I gave you working code for a working algorithm, and mentioned an even better algorithm, do with it what you will.
Sir, there's no reason to be frustrated. I'm actually using your code right now and it's working as a charm.

Last edited by Duugu : 02-12-14 at 09:07 AM.
  Reply With Quote
02-12-14, 09:14 AM   #25
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by Malsomnus View Post
Suppose the values are 170, 185, 160? Then you turn it into 170, -175, 160, and have the same problem, because circles have no magic spots on them that makes problems go away, on account of being perfectly symmetrical.
The intended use is to have an action bar follow the tangent line of a function. An action bar should not be upside down which is what values around 180 degrees would do. So if you stick to +/- 180 degree values you no longer need to check for the 0 - 360 degree boundary.

If his values were for something that did make full use of 360 degrees then sure you will have a point where you need special case handling. Since that is not the case then you use that knowledge to make the data and code easier to work with.

That said, I still think he should post the code that is giving him those values so that it can be tweaked instead of trying to "smooth" it out. By changing the values used he is effectively just using a different base function so why not use that different function from the outset?
  Reply With Quote
02-12-14, 09:43 AM   #26
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Vrul View Post
The intended use is to have an action bar follow the tangent line of a function. An action bar should not be upside down which is what values around 180 degrees would do. So if you stick to +/- 180 degree values you no longer need to check for the 0 - 360 degree boundary.
My action bar can be in any position or shape. Even upside down, a complete circle or whatever.

Originally Posted by Vrul View Post
That said, I still think he should post the code that is giving him those values so that it can be tweaked instead of trying to "smooth" it out. By changing the values used he is effectively just using a different base function so why not use that different function from the outset?
The values are calculated from the tangent vector of the bezier points. I'm not even sure if the problem is in my bezier implementation or within the calculation of the angle. I'll try to post it tonight.
  Reply With Quote
02-12-14, 09:49 AM   #27
Nimhfree
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 267
Assuming you can plot the positions of where each action item will appear on your arbitrary curve, is the problem that you want the buttons to line up nicely next to each other and they are not in some cases based on your actual curve shape?

In other words: (1) you create this mathematic curve, (2) attempt to apply buttons, but because the buttons are squares or whatever shape you have them they do not fit nicely together, (3) want to make the buttons look nice along the curve so want to alter the curve to attempt to fit your original curve within the limits the shape of the buttons pose, (4) need to replot the points where the buttons will go based on this curve shaping.

Last edited by Nimhfree : 02-12-14 at 09:51 AM.
  Reply With Quote
02-12-14, 11:53 AM   #28
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Nimhfree View Post
Assuming you can plot the positions of where each action item will appear on your arbitrary curve, is the problem that you want the buttons to line up nicely next to each other and they are not in some cases based on your actual curve shape?

In other words: (1) you create this mathematic curve, (2) attempt to apply Buttons, but because the buttons are squares or whatever shape you have them they do not fit nicely together, (3) want to make the buttons look nice along the curve so want to alter the curve to attempt to fit your original curve within the limits the shape of the buttons pose, (4) need to replot the points where the buttons will go based on this curve shaping.
I don't try to alter the curve or the buttons position on the curve. I simply rasterize the position of the button by the x/y coordinates of the mathematic bezier curve.

I'm trying to fix the not perfectly matching rotation of some buttons.

Now, why is the rotation not always correct? I'll try to explain it. It's challenging, as I'm more or less a math noob and my english is not that good, but I'll try.

The rotation angle is calculated by the tangent of the curve point (1st derivate) the specific button is placed on. It's the angle of the point tangent vector and the y-axis.

But, due to it's nature, the bezier curve is not a set of homogenous points. Meaning the interval from one point to the next point on the curve path is not equal for all curve points. The points may be spaced too far apart if the curve radius is very small and there are many points in areas where the curve is close to linear.

So I have non-homogenous path points and at the same time I have to place the buttons in a fixed interval on the path. This means, in some cases (usually at a small radius) I don't have a proper tangent vector (as there is no curve point that perfectly matches the position of the button).
I'll have to use a tangent/point that is as close as possible. And this leads to a slightly incorrect rotation angle.

I could fix this by calculating much more path points, but this needs an inaceptable amount of system ressources. So just 'smoothing' the degree values later on by calculating an average was my 'noob version' of a simple way to fix that.

[e] Due to the small value range (like x/y coordinates of +/- 300 or lower for the knots/control points and small tangent vectors with some path points) I'm pretty sure that there are also rounding differences in specific scenarios. And those rounding errors transform into an angle that is like one degree to small or to big.

Last edited by Duugu : 02-12-14 at 12:48 PM.
  Reply With Quote
02-12-14, 05:35 PM   #29
Nimhfree
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 267
Your English explaining this is much better than I could explain in any other language. :-)

Since you say that you have to place the buttons in a fixed interval on the path, why can't you just compute the position on the path for where the button is to be placed, and then compute the tangent from that point to determine the angle?

Personally I think you will run into problems for a wide variety of curves because, for example, if the curve looks like a U the buttons could hit each other in the bottom of the U. And if you were trying to evaluate the Y position from an X position, for example, you would have problems with the U because of the vertical aspects, and with a C because of more than one X value. You might need to use some complicated math to break apart your curve into smaller "straight lines" to attempt to get the right locations.
  Reply With Quote
02-12-14, 06:53 PM   #30
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Nimhfree View Post
Since you say that you have to place the buttons in a fixed interval on the path, why can't you just compute the position on the path for where the button is to be placed, and then compute the tangent from that point to determine the angle?
Uhm. Uhhhhhhhm. I ... uhm. I can't compute a bezier point out of x/y coordinates. Hm. I could calculate new points between the two closest points. To be honest ... I never thought about doing it that way. Thanks.

Originally Posted by Nimhfree View Post
Personally I think you will run into problems for a wide variety of curves because, for example, if the curve looks like a U the buttons could hit each other in the bottom of the U. And if you were trying to evaluate the Y position from an X position, for example, you would have problems with the U because of the vertical aspects, and with a C because of more than one X value. You might need to use some complicated math to break apart your curve into smaller "straight lines" to attempt to get the right locations.
Yes. That's true. But those problems are already solved. Actually I'm doing some math to place the buttons not just in fixed intervals. I didn't mentioned it below to keep the my description as simple as possible.

The button shape is transformed according to the buttons position and angle. So the buttons never hit/overlap each other. Like with the second and third bar in the screenshot below.
At least something that is working as expected.

  Reply With Quote
02-12-14, 07:17 PM   #31
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Okay what kinda evil hax did you used to transform thoose icons like that? I MUST KNOW IT.
  Reply With Quote
02-12-14, 07:22 PM   #32
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
SetTexCoord() with 8 arguments to transform the shape. We've discussed it in this thread: http://www.wowinterface.com/forums/s...ad.php?t=48832
The rotation is an 'rotation' type animation.

Last edited by Duugu : 02-12-14 at 07:35 PM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » I need an idea, approach or algorithm to solve an development issue

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off