616{
621
622 if(calcNorm) { *validNorm = false; }
623
624
625
626
627
628
629
630
631
633
634
635
636 G4double B = (-rho2 + paraRho2) * vRho2;
637
638 if ( rho2 < paraRho2 &&
sqr(rho2 - paraRho2 - 0.25 * tol2) > tol2 * paraRho2
640 {
641
642
644 {
645
646
647
648
649
650 intersection = (dz - p.
z()) / v.
z();
652
654 {
655 if(calcNorm)
656 {
658 if(r2 < tolh || ip.
perp2() >
sqr(r2 - tolh))
659 {
662 }
663 *validNorm = true;
664 }
665 return intersection;
666 }
667 }
668 else if(v.z() < 0)
669 {
670
671
672
673
674
675 intersection = (-dz - p.
z()) / v.z();
677
679 {
680 if(calcNorm)
681 {
683 if(r1 < tolh || ip.
perp2() >
sqr(r1 - tolh))
684 {
687 }
688 *validNorm = true;
689 }
690 return intersection;
691 }
692 }
693
694
695
696 if(vRho2 == 0)
697 {
698 intersection = ((rho2 - k2)/k1 - p.
z())/v.z();
699 if(calcNorm)
700 {
704
705 *validNorm = true;
706 }
707 return intersection;
708 }
709 else if( ((A <= 0) && (B >=
sqr(A) * (
sqr(vRho2) - 1))) || (A >= 0))
710 {
711
712
713
714
715 A = A/vRho2;
716 B = (k1 * p.
z() + k2 - rho2)/vRho2;
717 intersection = B/(-A + std::sqrt(B +
sqr(A)));
718 if(calcNorm)
719 {
723 *validNorm = true;
724 }
725 return intersection;
726 }
727 std::ostringstream message;
728 message << "There is no intersection between given line and solid!"
731 << " v = " << v;
732 G4Exception(
"G4Paraboloid::DistanceToOut(p,v,...)",
"GeomSolids1002",
734
735 return kInfinity;
736 }
738 ||
sqr(rho2 - paraRho2 - 0.25 * tol2) < tol2 * paraRho2 )
739 && std::fabs(p.
z()) < dz + tolh)
740 {
741
742
744
745 if(std::fabs(p.
z()) > dz - tolh)
746 {
747
748
749 if( ((v.z() > 0) && (p.
z() > 0)) || ((v.z() < 0) && (p.
z() < 0)) )
750 {
751 if(calcNorm)
752 {
753 *validNorm = true;
756 else
758 }
759 return 0;
760 }
761
762 if(v.z() == 0)
763 {
764
765
766
767
771 intersection = (-pDotV + std::sqrt(A +
sqr(pDotV))) / vRho2;
772
773 if(calcNorm)
774 {
775 *validNorm = true;
776
779 * intersection, -k1/2).
unit()).unit();
780 }
781 return intersection;
782 }
783 }
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805 if(v.z() > 0)
806 {
807
808
809 intersection = (dz - p.
z()) / v.z();
811
813 {
814 if(calcNorm)
815 {
816 *validNorm = true;
818 }
819 return intersection;
820 }
821 else if(ip.
perp2() <
sqr(r2 + tolh))
822 {
823 if(calcNorm)
824 {
825 *validNorm = true;
829 }
830 return intersection;
831 }
832 }
833 if( v.z() < 0)
834 {
835
836
837 intersection = (-dz - p.
z()) / v.z();
839
841 {
842 if(calcNorm)
843 {
844 *validNorm = true;
846 }
847 return intersection;
848 }
849 else if(ip.
perp2() <
sqr(r1 + tolh))
850 {
851 if(calcNorm)
852 {
853 *validNorm = true;
857 }
858 return intersection;
859 }
860 }
861
862
863
864 if(std::fabs(vRho2) > tol2)
865 {
866 A = A/vRho2;
867 B = (k1 * p.
z() + k2 - rho2);
869 {
870 B = (B)/vRho2;
871 intersection = B/(-A + std::sqrt(B +
sqr(A)));
872 }
873 else
874 {
875 if(normal.
dot(v) >= 0)
876 {
877 if(calcNorm)
878 {
879 *validNorm = true;
881 }
882 return 0;
883 }
884 intersection = 2.*A;
885 }
886 }
887 else
888 {
889 intersection = ((rho2 - k2) / k1 - p.
z()) / v.
z();
890 }
891
892 if(calcNorm)
893 {
894 *validNorm = true;
896 + intersection * v.y(), - k1 / 2);
898 }
899 return intersection;
900 }
901 else
902 {
903#ifdef G4SPECSDEBUG
905 {
906 G4Exception(
"G4Paraboloid::DistanceToOut(p,v,...)",
"GeomSolids1002",
908 }
909 else
910 G4Exception(
"G4Paraboloid::DistanceToOut(p,v,...)",
"GeomSolids1002",
911 JustWarning,
"There's an error in this functions code.");
912#endif
913 return kInfinity;
914 }
915 return 0;
916}
double dot(const Hep3Vector &) const