|
Thanks much!
I tried the third option on this result already and the problem I am having is that % will not work with floats, doubles but only with integers I get a compile error when I try it.
x % y will not compile unless the types for x and y are integer only.
So I tried multiplication to get the number rounded up to an integer, and then multiply the 360 by the same factor and then do that math and I am trying to work with that.
I suspect I may have to invert the signs first and then do the third step or I might not get the expected results I need....
0 .. 360 where 0 and 360 are north and 90 is East, and West is 270.
Been there, done that, forgot why!
|
|
|
|
|
Garry Freemyer wrote: x % y will not compile
Sorry, my mistake.
For 0=North, 90=East, 180=South, 270=West, this is what I would add after bearing=180.0*bearing/Math.PI; :
bearing=90.0-bearing;
if (bearing<0.0) bearing+=360.0;
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text (not TextBoxes), and PictureBoxes for pictures (not drawings).
modified on Friday, June 10, 2011 12:31 PM
|
|
|
|
|
Oh this is looking promising here. I got the correct bearings out of this when I asked about paradise to san diego and from paradise to colorado springs ... this is looking good!!
I'll do more testing and let you know but it's looking good so far!
Been there, done that, forgot why!
|
|
|
|
|
Another idea to get North=0, East=90 is even simpler: just swap the formulae for x and y!
You still need the negative-test if you want results in [0, 360) only.
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text (not TextBoxes), and PictureBoxes for pictures (not drawings).
modified on Friday, June 10, 2011 12:31 PM
|
|
|
|
|
Hmm Interesting, so just swap the arguments.
Well, I might try it later, I am still afraid of this monster, and am inclined to think that if it's working don't be too fast to try to fix it right after I have gone past the 12th round and my entire being is still reeling from it all.
If your solution works, you might consider posting this as an example on Code Project, in C# on how to find this ....
After searching for three weeks for a complete solution, I can tell you that there are dozens of others who like me could not find a solution ... Yours is the only complete solution with code that addresses the question asked. I found dozens of replies to folks who asked my question, but got the answer in the form of bearings where east was zero ... Something that should have been mentioned or they did not finish answering the question or left functions out of the code.
Been there, done that, forgot why!
|
|
|
|
|
Gee, all I did was take the formula you were using, and write a C# test app, making sure to include the greater Antwerp region to make sure the results made sense, and they did to me.
I had to look on the map to find and see relative position of Paradise and San-Diego, and I accepted the outcome. But then for me zero degrees has always pointed to the right, as with a protractor[^] (another word I learned todsy).
If you want to see an article on the subject, I suggest we work together; maybe you could do text and images, I could take care of coding and downloads (I could proofread too, finding most typo's, but I trust you would be better as far as vocabulary, grammar and style go).
|
|
|
|
|
Well, yeah I do have a different meaning to fix something.
I would be willing to do the wording, and put in the final code.
All articles I saw about converting to the range I needed said to use a form of a modulus operator, but NONE of them took into account that the modulus operator required integer operators.
Reminds me of years ago, I wanted to write a screen saver but all the code out there fell on it's face, and then I wanted to write one that worked on multiple monitors. The existing examples were not compilable or incomplete.
So I wrote one in C# under Visual Studio that worked with 2003, or 2005 with no mods. Folks loved it, as far as I know it's the best out there. You can replace my functions with your own graphics functions and plug it right in and go.
I spent weeks trying to iron out a problem where the screen saver would just mysteriously lock up. I finally got it fixed and then a windows update caused it to come back again.
I was not willing to go revisit the thing and go through weeks of hell, where the thing might crash immediately or crash in 2 days of constant running.
If you are curious it should be among my articles. I put it on Code Project a few years ago.
Been there, done that, forgot why!
|
|
|
|
|
Hi Garry,
I did send you an email message several days ago trying to get in touch with you directly, but since the CP email is not working reliably again, I now suggest you create a geodesic problem solvers group, which I could join, so we can collaborate on the article.
Groups are a new feature on CP, I don't know exactly how it works, but we'll see...
Regards,
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text output (not TextBoxes), and PictureBoxes for pictures (not drawings).
modified on Friday, June 10, 2011 12:32 PM
|
|
|
|
|
Garry Freemyer wrote: don't be too fast to try to fix it
"to fix" seems to have a special meaning with you
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text (not TextBoxes), and PictureBoxes for pictures (not drawings).
modified on Friday, June 10, 2011 12:32 PM
|
|
|
|
|
I am trying to to do a similar thing in C# (don't worry I am also a C++ developer).
Did you managed to work this out.
I actually need to plot a point on a line given the start point and distance. I also happen to know the end point.
Therefore I should be able to calculate the bearing between to points, then use this bearing, distance and start point to work out the lat long.
However I am stuck working out the bearing!
Can you help?
|
|
|
|
|
Please can some one help me how to split a single mp3 file into 2 or 3 mp3 files??
Thanx
Noor
|
|
|
|
|
Simply speeking, search BinaryReader and BinaryWriter in MSDN, you will find what you want.
I Love KongFu~
|
|
|
|
|
You decompress the mp3 data into an array of samples, split the samples, and compress each as new mp3 files.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi all, I'm new to socket programming and need help with an error.
I'm coding a project that will send Hex bytes to a comm port on a network. So far I can connect and send the correct values to the comm port no problem but when I hit the disconnect Button I get a "Program has encountered a problem and needs to close" message.
I've posted my code below, if anyone can please help I would be extremely grateful.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace AsyncTcpClient
{
public partial class Form1 : Form
{
private Socket client;
private byte[] data = new byte[1024];
private int size = 1024;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void connectButton_Click(object sender, EventArgs e)
{
string ipAddress;
ipAddress = ipAddressTextBox.Text;
connStatusTextBox.Text = "Connecting ...";
Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint iep = new IPEndPoint(IPAddress.Parse(ipAddress), 49510);
newsock.BeginConnect(iep, new AsyncCallback(Connected), newsock);
}
private void disconnectButton_Click(object sender, EventArgs e)
{
client.Close();
connStatusTextBox.Text = "Disconnected";
}
private void Connected(IAsyncResult iar)
{
client = (Socket)iar.AsyncState;
try
{
client.EndConnect(iar);
connStatusTextBox.Text = "Connected to: " + client.RemoteEndPoint.ToString();
client.BeginReceive(data, 0, size, SocketFlags.None, new AsyncCallback(ReceiveData), client);
}
catch (SocketException)
{
connStatusTextBox.Text = "Error connecting";
}
}
private void ReceiveData(IAsyncResult iar)
{
Socket remote = (Socket)iar.AsyncState;
int recv = remote.EndReceive(iar);
string hex1 = BitConverter.ToString(data, 0,recv);
resultsRichTextBox.Text = hex1.ToString();
if (hex1 == "50-01")
{
label01.BackColor = Color.Green;
label02.BackColor = Color.Red;
label04.BackColor = Color.Red;
}
else if (hex1 == "50-02")
{
label02.BackColor = Color.Green;
label01.BackColor = Color.Red;
label04.BackColor = Color.Red;
}
else if (hex1 == "50-04")
{
label04.BackColor = Color.Green;
label01.BackColor = Color.Red;
label02.BackColor = Color.Red;
}
else if (hex1 != "50-01" || hex1 != "50-02" || hex1 != "50-04")
{
label04.BackColor = Color.Red;
label01.BackColor = Color.Red;
label02.BackColor = Color.Red;
}
}
private void SendData(IAsyncResult iar)
{
Socket remote = (Socket)iar.AsyncState;
int sent = remote.EndSend(iar);
remote.BeginReceive(data, 0, size, SocketFlags.None, new AsyncCallback(ReceiveData), remote);
}
private void sendButton_Click(object sender, EventArgs e)
{
byte[] message = Encoding.ASCII.GetBytes(enterTextTextBox.Text);
enterTextTextBox.Clear();
client.BeginSend(message, 0, message.Length, SocketFlags.None, new AsyncCallback(SendData), client);
}
private void sendIntButton_Click(object sender, EventArgs e)
{
String toHex;
toHex = intTextBox.Text;
int NumberChars = toHex.Length;
byte[] bytes = new byte[NumberChars / 2];
for (int i = 0; i < NumberChars; i += 2)
{
bytes[i / 2] = Convert.ToByte(toHex.Substring(i, 2), 16);
}
Byte[] message = bytes;
intTextBox.Clear();
client.BeginSend(message, 0, message.Length, SocketFlags.None, new AsyncCallback(SendData), client);
}
private void timer1_Tick(object sender, EventArgs e)
{
}
}
}
|
|
|
|
|
SALAM SIR;
HOW ARE YOU?HOW CAN EASY LEANING VISUAL STUDIO .NET 2005 OR 2003?PLEASE HELP ME
AND ANY ONE PROGRAMMER HELP ME ONLINE IN YAHOO MESSENGER
MY ID IS mohammedali1989@yahoo.com
how can made clinic project in c#.net?please send me coding of clinic project in visual studio .net 2005 or 2003?
thanks sir you are great man.
mohammedali
|
|
|
|
|
...
"Well, we're getting "F"'d at work. WPF, WCF, and WWF... WTF?" --John Simmons
|
|
|
|
|
So, you want to write a rather complicated piece of software, having no experience in .NET?? And, you want to learn programming, having someone walk you through everything over Yahoo Messenger?? Is that correct??
|
|
|
|
|
this.bindingcontest[dataset,"datamember].postion++;
is it true to go from one record to the next record
thanks;
|
|
|
|
|
Sorry, I just didn't understand your question.
|
|
|
|
|
i am used the wizered to load and show the data from the data base
by drag and drop the table from dataset
and as you know all the control added to the form
i dont want to use nivagater the added automaticaly
i want make button for next,privious,move end ,move start
how can i make it
|
|
|
|
|
abu rakan wrote: I want [to] make button for next, previous, move end, move start
Start by putting buttons on your form.
Give the buttons proper IDs so they can be identified easily in code.
Double click each button will generate a code stub for handling the button event.
By the way, is this a Web application or a Windows application?
|
|
|
|
|
Neither could I, I think he wants to move around in a table, but I have no bloody idea.
|
|
|
|
|
Basically yes. From: BindingManagerBase.Position Property [^]:
Use the Position property to iterate through the underlying list maintained by the BindingManagerBase. To go to the first item, set the Position to 0. To go to the end of the list, set the Position to the value of the Count property minus 1.
The PositionChanged event occurs when the Position property value changes
|
|
|
|
|
thanks
i tried to use inside the button next
this.bindingcontext[dataset,"name of the table"].postion++;
but an error was occured
and thanks
|
|
|
|
|
What was the error?
Most likely you have to use:
this.BindingContext[dataset,"table.column"].Position++;
Also this should refer to an object which is bound to the dataset you use (textbox, label etc).
|
|
|
|
|