|
Hi all, does anyone have a function to shear a list of coordinates? I have four coordinates which make up a square, and would like to shear either it along the x or y axis. I need an equation that re-calculates each coordinate so that :
current-x-coordinate = ????
current-y-coordinate = ????
the results of this equation should produce results similar (roughly) to this example when used with the appropriate shear factor (this is a graphics project so 0,0 is the top-left):
SQUARE
50,50
50,100
100,100
100,50
SHEARED RESULT
75,50
100,50
100,100
125,50
Any help as to where I may get a rough answer would be wicked, thanks for reading this far though. I have tried the articles on this site, but I can't find the actual mathematics that I need to insert into my function.
Many thanks,
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
If I'm understanding correctly your request, shearing, as well as shrinking, strechting and rotating are linear transformations. If you combine a linear transformation with an offset, you have an affine transformation. An affine transformation is given by six parameters which we'll call a11,a12,a21,a22,b1 and b2, so that points with coordinates (x,y) are transformed to coordinates (x',y') given by:
x' = a11*x + a12*y + b1,
y' = a21*x + a22*y + b2.
This is trivially implemented in C++, the problem remaining is how to identify the six parameters for a given transformation. In the general case you take three points and their corresponding transformed points and plug the coordinates into these equations, giving you six equations and six variables that you can solve manually or with your favorite maths package. In the particular case of a horizontal shear, we have
a21=0,
a22=1,
b2=0,
so you nedd only two points to solve the remainig parameters.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your answer Joaquin, it is unbelievably superb, I just have a couple of small questions, in your response you mention b21=0, but where is b21 used? also you mention a11,a12,a21 and a22 but you use a11,a21,a21 and a22? could you just clarify this a little bit for me, I`m a titchy bit short of the answer (I am impressed with your explanation, I wouldn't have come up with this in a million light years). What does a11 equal? Last thing, Do I need to know the line equation constants to be able do this (I can get them)? I`m basically trying to do this with only coordinates at moment.
_ _
|_| -> /_/
I look forward to your response
Many Thanks,
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
You've spotted two typos on my reply, please take a look at it again, they're already fixed.
What does a11 equal?
Well, in the case of a horizontal shearing preserving x-scale (i.e. a rectangle transformed under this shear has the same width), a11=0. So this leaves you with basically two free parameters to play with, a21 and b1. In fact, every choice of these two parameters will produce a x-shear-like transformation, experiment and see the results.
Last thing, Do I need to know the line equation constants to be able do this (I can get them)?
I'm not sure I'm getting your question. Affine operations transform lines into lines, so in order to have a line segment (x1,y1)--(x2,y2) transformed, just transform its extreme points and draw line between those.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi guys, has anyone managed to get STLport's Standard Template Library working with Visual C++ 6.0? If you have please guide me on doing the same because I can't get mine to work.
Regards
Senkwe
Just another wannabe code junky
|
|
|
|
|
Had the same problem myself recently. I can't get the IOStreams stuff to compile, but if you ignore that, and just run the nmake command for preparing the rest of the library, it all links in fine.
LMK if you're still having trouble after trying that.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Hello everybody!
How to find a real printing rectangle, which supports the printer.
At use CPrintInfo::m_rectDraw , the right and bottom borders remain behind edge and are not visible!
Best regards,
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|
Hi,
I am using a Audio Player ActiveX in VB and VC++ 6.0.
In VB the control runs fine, but in VC++ the control freezes the window
when I play a song.
I'm using CreateInstance method in VC++ to instantiate the control
Can someone tell me what I should do?
Sansky
|
|
|
|
|
Its hard to answer without seeing the code, but did you call CoInitialize or CoInitializeEx?
Hope this helps,
Bill
|
|
|
|
|
i ve created file using CFile.
and write strings into it...
writeerror(string)
{
CFile file;
file.Open(name,CFile::modewrite);
file.seektoend();
file.write(string , lenthof(string));
}
i am putting "\n" at the end of the string ..
string i am writing gets appended at the end of previous string...
i want it to be written at next line
thanks,
patty
|
|
|
|
|
It's either \n\r, or \r\n, I always forget which. I thought for ages I had it right, then found out I was wrong, and I've been confised ever since.
But it's one of them, anyhow.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Its \r\n
Roger Allen
Sonork 100.10016
|
|
|
|
|
Some windows editors will work with a single '\n'.
On the other hand, "\r\n" won't look right with the vi editor on Unix.
|
|
|
|
|
Yeah, I just noticed that.
The \r is shown as ^M
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
I always always remember it as \r\n
In school I used to a little asm and I used to define a macro-string [I was using MASM] crlf as 0Dh,0Ah
So I kept rememberin it as carriage return line feed
Thus \r comes first [Return]
and \n comes second "liNe feed"
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
\n is the new line character and \r is return character. Some editors need only \n(such as the DevStudio editor) but others (such as Notepad) needs both to correctly display text in separate lines.
BTW, the ascii value for \n is 10, and for \r is 13. Hope I remember it right.
|
|
|
|
|
I have an explorer like app and I use de IContextMenu in order to handle de context menu. Why my ‘Open With’ menu is not shown correctly like in the Windows Explorer?
Windows Explorer - Open With menu opens a submenu with apps (like Microsoft Word, WordPad, etc.) and 'Choose program...' options.
My App - Open With menu opens a submenu with only one option 'Open With' (again)
|
|
|
|
|
That's because Explorer does extra work and fills in the Open With menu itself. The Send To menu will have the same problem, BTW. You'll need to duplicate what Explorer does. For Send To, enum the contents of \windows\sendto (or the appropriate user dir on NT). Check out WndTabs, which I know has this feature, if you need source.
--Mike--
My really out-of-date homepage
He who laughs last, didn't get the punchline and is just laughing so he won't look silly.
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Thanks for your explanation.
|
|
|
|
|
Hi,
I would like to get the list of printers connected to my PC.I had used Enumprinter() ,but it never worked.
Could anyone pl tell me the proper way of using the Enumprinter () for getting both the network & local printer.
I am using a simple win32 sdk.no mfc support.
My target OS's are Windows ME & 98.
can anyone pl help me..
Neha
|
|
|
|
|
Hi,
I´m having problems with my splitters windows, sometimes when I remove the view and call close frame, then it calls RecalcLayout ( well... without windows existings and maybe nothing there...), so... what I would like to do is something like...:
Onclose...
StopBotheringMeWithTheRecalcLayoutStuff
Make all the stuff to close and destroy
How can I do that ?, I have tried two things, the first one is SetRedrawFalse on the splitter but nothing..., the second one moving the focus to the main window but no result as well... any idea ?, thanks, Bye !
Braulio
|
|
|
|
|
Have a member variable BOOL bClosing;
Override RecalcLayout, and only call base class implementation if bClosing is false.
Set bClosing to TRUE when your close starts.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Thanks,
I thought doing something like that, but thought that there should be some already done thing to do something like that ( I think it´s a common problem).
Thanks, Bye !
Braulio
|
|
|
|
|
I am trying to execute soem arbitrary file using code below.
SHELLEXECUTEINFO si;
ZeroMemory(&si,sizeof(si));
si.cbSize = sizeof(si);
si.hwnd = NULL;
si.lpVerb = "Open";
si.nShow = SW_SHOW;
si.lpFile = szFileName;
si.lpParameters = NULL;
si.lpDirectory = m_strCurDir;
si.fMask = SEE_MASK_FLAG_NO_UI;
ShellExecuteEx(&si);
My problem is that for ".dsw" files (Visual C++ project files) this function fails (with "no association" error).
What can I do to successfully execute even this kind of files?
Does anyone has a code for that (registry digging?) ?
Thanks in advance.
Miroslav Rajcic
|
|
|
|
|
What happens when you manually double click on a dsw file?
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|