-
June 29th, 2020, 03:38 PM
#1
Math 3D: how get 2D from 3D vectors?
i have a calculation for convert 3D vectors to 2D vectors:
(isn't a C++ code, but you get the point)
Code:
Private Function ConvertPositon3DTo2D(Position As Position3D, World3DSize As Size3D) As POINTAPI Dim ConvertedPosition As POINTAPI
Dim PosZZDepth As Long
PosZZDepth = Position.Z + World3DSize.distance
If (PosZZDepth = 0) Then PosZZDepth = 1 'avoiding division by zero
Dim Width As Double
Dim Height As Double
Width = World3DSize.Width / 2
If (Width = 0) Then Width = 0
Height = World3DSize.Height / 2
If (Height = 0) Then Height = 0
ConvertedPosition.X = (Position.X * World3DSize.distance / PosZZDepth) + Width ' i add '+ Width', because it's the center of screen
ConvertedPosition.Y = (Position.Y * World3DSize.distance / PosZZDepth) + Height
ConvertPositon3DTo2D = ConvertedPosition
End Function
i need ask 1 thing that it's killing me and make confused: if the X and Y are negative(on 2D), why it be can drawed on camera in a diffent way?(like seen 2 triangles)
see the image:
https://imgur.com/OXk0L26
unless i miss something that i don't know.. please can anyone explain to me what i'm doing wrong on these conversion?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|