BlueIshDan
☠
- Local time
- Today, 20:10
- Joined
- May 15, 2014
- Messages
- 1,122
Here it goes. I'm working with multiple coordinate systems with ouR engineering data here at work. I need to select an area in an outer scope grid (Main grid) and get the x, y values in the sub coordinate systems.
I have the formula I just can't wake up enough to get it right in my code.
If anyone could help figure this out with me I'd be SO grateful!
Here is what the Formula is.
		
		
	
	
		 
	
Here is what my code is as of now. Don't mind the variants I just haven't seen the behaviour of the numbers yet, it will be done properly later on.
	
	
	
		
 I have the formula I just can't wake up enough to get it right in my code.
If anyone could help figure this out with me I'd be SO grateful!

Here is what the Formula is.
Here is what my code is as of now. Don't mind the variants I just haven't seen the behaviour of the numbers yet, it will be done properly later on.
		Code:
	
	
	Option Explicit
Const MAIN_MAX_X As Integer = 11600
Const MAIN_MAX_Y As Integer = 10000
Private Sub rectCoordinateScope_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
    
    Dim x_percent As Variant: x_percent = Round(x / rectCoordinateScope.Width, 2)
    Dim y_percent As Variant: y_percent = Round(Y / rectCoordinateScope.Height, 2)
    
    lblMainX.Caption = MAIN_MAX_X * x_percent
    lblMainY.Caption = MAIN_MAX_Y * y_percent
    
    txtSouthGridX.Value = ConvertX(1, 0, CLng(lblMainX.Caption), CLng(lblMainY.Caption), 2000)
    txtSouthGridY.Value = ConvertY(1, 0, CLng(lblMainX.Caption), CLng(lblMainY.Caption), 2000)
    
End Sub
Public Function ConvertX(ByVal coordinate_scale As Variant, _
                         ByVal rotation As Variant, _
                         ByVal from_x As Variant, _
                         ByVal from_y As Variant, _
                         ByVal translation_x As Variant) As Variant
                         
    ConvertX = Sqr(coordinate_scale * (from_x * Cos(0) - from_y * Sin(0)) + translation_x)
    
End Function
Public Function ConvertY(ByVal coordinate_scale As Variant, _
                         ByVal rotation As Variant, _
                         ByVal from_x As Variant, _
                         ByVal from_y As Variant, _
                         ByVal translation_y As Variant) As Variant
                         
    ConvertY = Sqr(coordinate_scale * (from_x * Cos(0) + from_y * Sin(0)) + translation_y)
    
End Function 
	 
			 Which I'm not
 Which I'm not  
			 
			
 
 
		 
 
		 
 
		 
 
		 
 
		