AVertex.Coord (x1, y1, z1);
// project ray from camera onto grid plane
- if (!myCamera->IsOrthographic())
- {
- gp_Vec aDirCamera2Point = gp_Vec (myCamera->Eye(), gp_Pnt (x1, y1, z1)).Normalized();
- gp_Vec aVecCamera2Orig = gp_Vec (myCamera->Eye(), gp_Pnt (x0, y0, z0));
- Standard_Real aDistPointPlane = aVecCamera2Orig.Dot (aPlaneNormal) / aDirCamera2Point.Dot (aPlaneNormal);
- aPointOnPlane = gp_Vec (myCamera->Eye().XYZ()) + aDirCamera2Point * aDistPointPlane;
- }
- else
- {
- gp_Vec aDirCamera = myCamera->Direction();
- gp_Vec aVecOrig2Point = gp_Vec (gp_Pnt (x0, y0, z0), gp_Pnt (x1, y1, z1));
- Standard_Real aDistPointPlane = aVecOrig2Point.Dot (aPlaneNormal) / aDirCamera.Dot (aPlaneNormal);
- aPointOnPlane = gp_Vec (x1, y1, z1) + aDirCamera * aDistPointPlane;
- }
+ gp_Vec aProjection = myCamera->IsOrthographic()
+ ? gp_Vec (myCamera->Direction())
+ : gp_Vec (myCamera->Eye(), gp_Pnt (x1, y1, z1)).Normalized();
+ gp_Vec aPointOrigin = gp_Vec (gp_Pnt (x1, y1, z1), gp_Pnt (x0, y0, z0));
+ Standard_Real aT = aPointOrigin.Dot (aPlaneNormal) / aProjection.Dot (aPlaneNormal);
+ aPointOnPlane = gp_Vec (x1, y1, z1) + aProjection * aT;
if (IsRectangular) {
Standard_Real XS, YS;
--- /dev/null
+puts "============"
+puts "CR26435"
+puts "============"
+puts ""
+#######################################################################
+# Visualization - V3d_View::ConvertToGrid returns wrong coordinates for non-orthogonal projection
+#######################################################################
+
+vinit View1 w=400 h=400
+vgrid r l 0 0 5 5 0
+
+# 1. Check convert to grid for axonometric projection. Grid is at origin.
+vaxo
+set output [vconvert 200 200 grid]
+
+checkreal "vconvert axo - grid origin" [lindex $output 2] 5.0 1e-7 0.0
+checkreal "vconvert axo - grid origin" [lindex $output 3] -5.0 1e-7 0.0
+checkreal "vconvert axo - grid origin" [lindex $output 4] 0.0 1e-7 0.0
+
+# 2. Check convert to grid for top projection. Grid is at origin.
+vtop
+set output [vconvert 200 200 grid]
+
+checkreal "vconvert top - grid origin" [lindex $output 2] 0.0 1e-7 0.0
+checkreal "vconvert top - grid origin" [lindex $output 3] -5.0 1e-7 0.0
+checkreal "vconvert top - grid origin" [lindex $output 4] 0.0 1e-7 0.0
+
+# 3. Check convert to grid for axonometric projection. Grid is not at origin.
+vpriviledgedplane 0.0 0.0 10.0 0 0 1 1 0 0
+
+vaxo
+set output [vconvert 200 200 grid]
+
+checkreal "vconvert axo - grid lifted" [lindex $output 2] 15.0 1e-7 0.0
+checkreal "vconvert axo - grid lifted" [lindex $output 3] -15.0 1e-7 0.0
+checkreal "vconvert axo - grid lifted" [lindex $output 4] 10.0 1e-7 0.0
+
+# 4. Check convert to grid for top projection. Grid is not at origin.
+vtop
+set output [vconvert 200 200 grid]
+
+checkreal "vconvert top - grid lifted" [lindex $output 2] 0.0 1e-7 0.0
+checkreal "vconvert top - grid lifted" [lindex $output 3] -5.0 1e-7 0.0
+checkreal "vconvert top - grid lifted" [lindex $output 4] 10.0 1e-7 0.0
+
+# do not save any image
+set only_screen 0