VB.NET Tutorial

Visual Basic .NET에 대한 설명서가 잘 정리된 웹페이지를 소개한다.
http://www.java2s.com/Tutorial/VB/CatalogVB.htm
키워드(keyword) 별로 어떻게 쓰이는지 알고 싶다면, 꼭 한 번 들를만 하다.
또한, 비주얼베이직 닷넷 말고 지구상에 존재하는 웬만한 프로그래밍 언어에 대한 설명서도 함께 있다. 여기서는 비주얼 베이직 닷넷만 연결해 놓은 것이다. 왜? 이 홈피의 주관심사여서. ^^
크리에이티브 커먼즈 라이센스
Creative Commons License

Posted by 솔라뷰

2009/02/26 21:21 2009/02/26 21:21
, , ,
Response
No Trackback , No Comment
RSS :
http://www.solarview.net/rss/response/232

3차원 벡터(또는 점)에 대한 구조체(structure)

3차원 벡터(또는 점)에 대한 구조체(structure)를 아래와 같이 작성할 수 있다.
<특이점>
1) 벡터의 성분은 X, Y, Z로 명백하므로 그냥 Public 변수로 설정함
2) 배열로 선언된 벡터 성분과도 호환되도록 함
- VB.NET의 Default Property를 이용함
- 사용예 :

Dim v1,v2 As Vector3D
Dim innerProduct As Single = v1(0)*v2(0) + v1(1)*v2(1) + v1(2)*v2(2)


구조체 소스코드
Public Structure Vector3D
Public X, Y, Z As Single
Public Shared ReadOnly ZeroVector As Vector3D = New Vector3D(0, 0, 0)

#Region "Constructors"
'Private Sub New()
'Nothing -> No default initialization
'End Sub
Public Sub New(ByVal x As Single, ByVal y As Single, ByVal z As Single)
Me.X = x
Me.Y = y
Me.Z = z
End Sub
Public Sub New(ByVal v As Vector3D)
Me.New(v.X, v.Y, v.Z) 'copy constructor
End Sub
#End Region

#Region "Properties"
''' <summary>
''' 배열로 선언된 벡터 성분과 호환이 되도록 작성함
''' </summary>
''' <param name="index">성분의 위치를 지정하는 값 0:x, 1:y, 2:z</param>
''' <value>해당성분의 값</value>
''' <returns>해당성분의 값</returns>
''' <remarks>
''' 왜 호환되게 했나고요?
''' c/c++로 짠 코드를 변환하다 보면, 배열로 간단하게 해결한 것들이 많아서요.
''' </remarks>
Default Public Property Elements(ByVal index As Short) As Single
Get
Dim i As Short = index Mod 3'실수를 방지하기 위해서
Select Case i
Case 0
Return X
Case 1
Return Y
Case 2
Return Z
End Select
End Get
Set(ByVal value As Single)
Dim i As Short = index Mod 3
Select Case i
Case 0
X = value
Case 1
Y = value
Case 2
Z = value
End Select
End Set
End Property
#End Region
''각종 Property와 Operator 등은 생략 ^^
End Class

크리에이티브 커먼즈 라이센스
Creative Commons License

Posted by 솔라뷰

2008/06/21 04:48 2008/06/21 04:48
, , ,
Response
No Trackback , No Comment
RSS :
http://www.solarview.net/rss/response/174

Intersection with a ray and an AABB

광선과 AABB가 교차하는지를 평가하는 함수이다. 이 함수는 Stefan Zerbst의 책 "3D Game Engine Programming"의 138~140쪽에 나오는 ZFXRay::Intersects 함수를 VB.NET으로 변환한 것이다. 이 함수의 원천적인 알고리즘은 Andrew Woo의 알고리즘에서 비롯한 것이다.

Function IntersectionAABBonText(ByVal RayDirection As Vector3D, ByVal RayOrigin As Vector3D) As Boolean
Dim RayInsideAABB As Boolean = True
Dim HitPoint As Vector3D
Dim MaxT As New Vector3D(-1.0F, -1.0F, -1.0F)
Dim Epsilon As Single = 0.00001F
'
'Find the x component
If (RayOrigin.X < Me.m_Min.X) Then
HitPoint.X = Me.m_Min.X
RayInsideAABB = False
If RayDirection.X <> 0.0F Then
MaxT.X = (Me.m_Min.X - RayOrigin.X) / RayDirection.X
End If
ElseIf (RayOrigin.X > Me.m_Max.X) Then
HitPoint.X = Me.m_Max.X
RayInsideAABB = False
If RayDirection.X <> 0.0F Then
MaxT.X = (Me.m_Max.X - RayOrigin.X) / RayDirection.X
End If
End If
'Find the y component
If (RayOrigin.Y < Me.m_Min.Y) Then
HitPoint.Y = Me.m_Min.Y
RayInsideAABB = False
If RayDirection.Y <> 0.0F Then
MaxT.Y = (Me.m_Min.Y - RayOrigin.Y) / RayDirection.Y
End If
ElseIf (RayOrigin.Y > Me.m_Max.Y) Then
HitPoint.Y = Me.m_Max.Y
RayInsideAABB = False
If RayDirection.Y <> 0.0F Then
MaxT.Y = (Me.m_Max.Y - RayOrigin.Y) / RayDirection.Y
End If
End If
'Find the z component
If (RayOrigin.Z < Me.m_Min.Z) Then
HitPoint.Z = Me.m_Min.Z
RayInsideAABB = False
If RayDirection.Z <> 0.0F Then
MaxT.Z = (Me.m_Min.Z - RayOrigin.Z) / RayDirection.Z
End If
ElseIf (RayOrigin.Z > Me.m_Max.Z) Then
HitPoint.Z = Me.m_Max.Z
RayInsideAABB = False
If RayDirection.Z <> 0.0F Then
MaxT.Z = (Me.m_Max.Z - RayOrigin.Z) / RayDirection.Z
End If
End If
'
'---- Ray origin inside bounding box
'광선의 시점이 박스 안에 있다. 이 판단이 내 프로그램에서 유용할 것인가?
'내 프로그램은 기본적으로 3D Face이기 때문에 정확한 판단이 아닐 수도 있다.
If RayInsideAABB Then
HitPoint = RayOrigin
Return True
End If
'
'---- Get largest of the maxT's for final choice of intersection
'최대값 구하기
Dim nPlane As Integer = 0
If (MaxT.Y > MaxT(nPlane)) Then nPlane = 1
If (MaxT.Z > MaxT(nPlane)) Then nPlane = 2
'
'---- Check final candidate actually inside box
If (MaxT(nPlane) < 0.0F) Then Return False
If nPlane <> 0 Then
HitPoint.X = RayOrigin.X + MaxT.X * RayDirection.X
If (HitPoint.X < Me.m_Min.X - Epsilon) OrElse (HitPoint.X > Me.m_Max.X + Epsilon) Then
Return False
End If
End If
If nPlane <> 1 Then
HitPoint.Y = RayOrigin.Y + MaxT.Y * RayDirection.Y
If (HitPoint.Y < Me.m_Min.Y - Epsilon) OrElse (HitPoint.Y > Me.m_Max.Y + Epsilon) Then
Return False
End If
End If
If nPlane <> 2 Then
HitPoint.Z = RayOrigin.Z + MaxT.Z * RayDirection.Z
If (HitPoint.Z < Me.m_Min.Z - Epsilon) OrElse (HitPoint.Z > Me.m_Max.Z + Epsilon) Then
Return False
End If
End If
Return True
End Function

크리에이티브 커먼즈 라이센스
Creative Commons License

Posted by 솔라뷰

2008/06/19 04:45 2008/06/19 04:45
,
Response
No Trackback , No Comment
RSS :
http://www.solarview.net/rss/response/173

[Webpage]3D Object Intersection

3D Object Intersection

3차원 객체들의 교차(혹은 충돌)여부를 검사하는 것은 그래픽관련 프로그래밍할 때, 매우 빈번하게 접하는 문제이다.
이런 문제들을 한 자리에 일목요연하게 정리한 웹페이지이다.
위치 : http://www.realtimerendering.com/int/
자체 설명
This page gives a grid of intersection routines for various popular objects, pointing to resources in books and on the web. For a unified static and dynamic object intersection and distance library (non-commercial use only, though), see the TGS collision system. The most comprehensive books on the subject are Geometric Tools for Computer Graphics (GTCG) and Real-Time Collision Detection (RTCD); the former is all-encompassing, the latter more approachable and focused.
크리에이티브 커먼즈 라이센스
Creative Commons License

Posted by 솔라뷰

2008/05/23 04:51 2008/05/23 04:51
,
Response
No Trackback , No Comment
RSS :
http://www.solarview.net/rss/response/170

DoEvents함수를 효과적으로 사용하기

DoEvents함수는 CPU-intensive code를 예방하는 방법 중의 하나이다.
수치해석과 같이 CPU계산량이 많은 응용프로그램일 경우, 계산에만 몰두하느라 다른 응용프로그램을 사용할 수 없게 된다. 해당 프로그램도 응답이 없어 마치 죽은(?) 듯한 반응을 보인다. 이를 방지하기 위해서 다른 응용 프로그램에도 CPU사용을 허락하는 것이 DoEvents함수이다.
이렇듯 좋은 취지의 함수이지만, 이 함수를 남발할 경우 오히려 계산속도가 현저히 떨어지는 상황을 맞이할 수 있다. 그럼 어떻게 할 것인가?

1)DLL 함수 선언
Public Declare Function GetInputState Lib "user32" () As Int32

2)함수 사용
If Not GetInputState() = 0 Then Application.DoEvents()


이렇게 하면 입력값이 있을 때만, DoEvents 함수를 호출한다.
그냥 DoEvents함수를 사용하는 경우보다 계산속도가 빠르다.
크리에이티브 커먼즈 라이센스
Creative Commons License

Posted by 솔라뷰

2008/05/20 10:20 2008/05/20 10:20
, ,
Response
No Trackback , No Comment
RSS :
http://www.solarview.net/rss/response/175

[webpage]Graphics Gems Repository

컴퓨터 그래픽 분야에서 광범위하게 사용되는 핵심적인 알고리즘과 그를 구현하는 코드가 공개된 사이트.
Graphics Gems 시리즈 책에 실려있는 모든 코드가 고스란히 정리되고 공개되어 있다.
해석프로그램인 SolarView에서 사용한 알고리즘 중 일부는 여기에서 제공한 것을 번역 또는 변환해서 사용하였다.

주소 : http://tog.acm.org/GraphicsGems/
내용 :
2D Geometry
2D Rendering
3D Geometry
3D Rendering
C Utilities
Curves and Surfaces
Frame Buffer Techniques
Image Processing
Matrix Techniques
Modeling and Transformations
Numerical and Programming Techniques
Radiosity
Ray Tracing


이 책은 알고리즘, 프로그램, 그래픽 프로그래머들에 필요한 수학적인 기술들을 담고 있다. 즉, 그래픽 프로그래머들이 프로그램을 작성할 때 도움을 주고자 만들어졌다. 이 책에 있는 기사들은 연구 논문이 아니며, 저널에 실린 것들과 컨퍼런스에서 나온 결과를 담고 있다. 수록된 내용들과 소스코드는 현재까지 모든 게임과 그래픽 전 분야에 걸쳐서 핵심적으로 사용되고 있는 것들이다. (교보문고 설명문 인용)
크리에이티브 커먼즈 라이센스
Creative Commons License

Posted by 솔라뷰

2008/04/13 03:17 2008/04/13 03:17
,
Response
No Trackback , No Comment
RSS :
http://www.solarview.net/rss/response/165

[webpage]Computational Geometry Algorithms Library

위치 : http://www.cgal.org/
내용 :
전산기하학에 필요한 알고리즘을 공개한 사이트. 아래는 사이트 내의 설명임
The goal of the CGAL Open Source Project is to provide easy access to efficient and reliable geometric algorithms in the form of a C++ library. CGAL is used in various areas needing geometric computation, such as: computer graphics, scientific visualization, computer aided design and modeling, geographic information systems, molecular biology, medical imaging, robotics and motion planning, mesh generation, numerical methods.

The Computational Geometry Algorithms Library (CGAL), offers data structures and algorithms like triangulations (2D constrained triangulations and Delaunay triangulations in 2D and 3D), Voronoi diagrams (for 2D and 3D points, 2D additively weighted Voronoi diagrams, and segment Voronoi diagrams), Boolean operations on polygons and polyhedra, arrangements of curves and their applications (2D and 3D envelopes, Minkowski sums), mesh generation (2D Delaunay mesh generation and 3D surface mesh generation, skin surfaces), geometry processing (surface mesh simplification, subdivision and parameterization, as well as estimation of local differential properties, and approximation of ridges and umbilics), alpha shapes, convex hull algorithms (in 2D, 3D and dD), operations on polygons (straight skeleton and offset polygon), search structures (kd trees for nearest neighbor search, and range and segment trees), interpolation (natural neighbor interpolation and placement of streamlines), shape analysis, fitting, and distances (smallest enclosing sphere of points or spheres, smallest enclosing ellipsoid of points, principal component analysis), and kinetic data structures.
크리에이티브 커먼즈 라이센스
Creative Commons License

Posted by 솔라뷰

2008/04/11 03:34 2008/04/11 03:34
, ,
Response
No Trackback , No Comment
RSS :
http://www.solarview.net/rss/response/168

« Previous : 1 : 2 : 3 : 4 : Next »