예제 #1
0
def AutoCheckTest(IncidentLight,Plane,ReflectedLight,TrasmittedLight,n1,n2):
    #'use the Reflectedlight to calculate the Incidentlight'
    r2 = np.array([0,0,0])
    r2 = Fun.CaRDir(ReflectedLight,Plane)


    #'use the Trasmitted light to calculate the Incidentlight'
    t2 = np.array([0,0,0])
    t2 = Fun.CaTdir(TrasmittedLight,Plane,n2,n1)
    

    if abs(np.linalg.norm(np.cross(IncidentLight.dn,r2))) <= 0.1:
        print('yes')
    else:
        print('-------->  R false for this point:--------<')
        IncidentLight.displayLight()
        print(r2)
        return False
    
    if abs(np.linalg.norm(np.cross(IncidentLight.dn,t2))) <= 0.1:
        print('ok')
    else:
        print('-------->  T false for this point:--------<')
        IncidentLight.displayLight()
        print('n1 : n2')
        print(n1,n2)
        print(t2)
        return False

    return True
예제 #2
0
def test1():
    a = Fun.Light()  # a is Incident light
    b = Fun.Plane()  # b is the Plane
    #The input of Function
    a.inc([-1, 1, 0], [1, -1, 0])
    b.inc([0, 0, 0], [0, 1, 0])
    n1 = math.sqrt(2)
    n2 = 1
    #The output should be

    r1 = (Fun.CaRDir(a, b) == Fun.Normalized(np.array([1, 1, 0]))).all()
    r2 = (Fun.CaPoint(a, b) == np.array([0, 0, 0])).all()
    r3 = (Fun.CaTdir(a, b, n1, n2) == Fun.Normalized(np.array([0, 0,
                                                               0]))).all()
    assert r1 & r2 & r3
예제 #3
0
파일: main.py 프로젝트: Mingyumaz/light123
        #'use the Test Case we set by hand'
        (a,b,n1,n2) = TS.InputLightPlane13()

    #''
    if Fun.JudgeCrossPoint(a,b):

        # calculate the reflected light and print the point and vector
        r.inc(Fun.CaPoint(a,b),Fun.CaRDir(a,b))
        print('The point and direction of the reflected light is:')
        r.displayLight()

        #'first judge if the total reflection will happen, Ture is not happen, and False is happen'
        if Fun.JudgeTotalReflection(a,b,n1,n2):

            # calculate the transmitted light and print the point and vector
            t.inc(Fun.CaPoint(a,b),Fun.CaTdir(a,b,n1,n2))
            print('The point and direction of the transmitted(refractedlight) light is:')
            t.displayLight()
            
            # if we will test or not, 
            # and we assume you dont want to see the figure, 100 figure is troublesome
            if Autotest == True:
                WriteN = TIS.AutoCheckTest(a,b,r,t,n1,n2)
                if WriteN:
                    print('ok',file= f)
                else:
                    print('wrong',file= f)
            else:
                # Display the picture of the lights and plane
                DisWP.DisplayWholeProcess(a,r,t,b)
        else: