//粘贴到帧上运行即可

var p1Start:Point = new Point(0,0);
var p1End:Point = new Point(50,50); var p2Start:Point = new Point(50,50);
var p2End:Point = new Point(100,100); var p:Point = new Point(); trace(checkPoint())
function checkPoint()
{
if (p1Start.x == p1End.x)
{
if (p2Start.x == p2End.x)
{
trace("平行线");
p = null;
}
else
{
p.x = p1Start.x;
p.y = p2Start.y+(p1Start.x-p2Start.x)/(p2End.x-p2Start.x)*(p2End.y-p2Start.y);
}
}
else if (p2Start.x == p2End.x)
{
p.x = p2Start.x;
p.y = p1Start.y+(p2Start.x-p1Start.x)/(p1End.x-p1Start.x)*(p1End.y-p1Start.y);
}
else
{
var K1:Number = (p1Start.y-p1End.y)/(p1Start.x-p1End.x);
var K2:Number = (p2Start.y-p2End.y)/(p2Start.x-p2End.x);
if (K1 == K2)
{
trace("平行线");
p = null;
}
else
{
var B1:Number = (p1Start.x*p1End.y-p1Start.y*p1End.x)/(p1Start.x-p1End.x);
var B2:Number = (p2Start.x*p2End.y-p2Start.y*p2End.x)/(p2Start.x-p2End.x);
p.x = (B2 - B1) / (K1 - K2);
p.y = K1 * p.x + B1;
}
}
return p;
}

  

AS3 求两条直线的交点的更多相关文章

  1. C++ 根据两点式方法求直线并求两条直线的交点

    Line.h #pragma once //Microsoft Visual Studio 2015 Enterprise //根据两点式方法求直线,并求两条直线的交点 #include"B ...

  2. 求两条直线相交点 AS3代码

    ,); ,); ,); ,); var p:Point = new Point(); trace(checkPoint()) function checkPoint() { if (p1Start.x ...

  3. Intersecting Lines--POJ1269(判断两条直线的关系 && 求两条直线的交点)

    http://poj.org/problem?id=1269 我今天才知道原来标准的浮点输出用%.2f   并不是%.2lf  所以wa了好几次 题目大意:   就给你两个线段 然后求这两个线段所在的 ...

  4. 计算两条直线的交点(C#)

    PS:从其他地方看到的源码是有问题的.下面是修正后的 /// <summary> /// 计算两条直线的交点 /// </summary> /// <param name ...

  5. poj 1269(两条直线交点)

    Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13481   Accepted: 59 ...

  6. 判断两条直线的位置关系 POJ 1269 Intersecting Lines

    两条直线可能有三种关系:1.共线     2.平行(不包括共线)    3.相交. 那给定两条直线怎么判断他们的位置关系呢.还是用到向量的叉积 例题:POJ 1269 题意:这道题是给定四个点p1, ...

  7. 两条直线(蓝桥杯)二分枚举+RMQ

    算法提高 两条直线   时间限制:1.0s   内存限制:256.0MB        问题描述 给定平面上n个点. 求两条直线,这两条直线互相垂直,而且它们与x轴的夹角为45度,并且n个点中离这两条 ...

  8. hdu 1086 You can Solve a Geometry Problem too 求n条直线交点的个数

    You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/3 ...

  9. 求空间内两条直线的最近距离以及最近点的坐标(C++)

    关键词:空间几何 用途:总有地方会用到吧 文章类型:C++函数展示 @Author:VShawn(singlex@foxmail.com) @Date:2016-11-19 @Lab: CvLab20 ...

随机推荐

  1. 161018、springMVC中普通类获取注解service方法

    1.新建一个类SpringBeanFactoryUtils 实现 ApplicationContextAware package com.loiot.baqi.utils; import org.sp ...

  2. 将txt文件数据转成bin文件.

    之前用牛逼的绘图以及分析bmp的像素文件的方法, 整理出汉字编码从: 0x4E00到0x9FA5, (维基上说是9FD5, 完了, 回头再更新吧.) https://en.wikipedia.org/ ...

  3. STM32外部中断.

    void EXTIX_Init(void){     EXTI_InitTypeDef EXTI_InitStructure;    NVIC_InitTypeDef NVIC_InitStructu ...

  4. TI CC254x BLE教程 3

    通用属性配置(Generic Attribute Profiles) 1. 数据在services里面以特征字(characteristics)的形式展示出来 如你所见, 特征字包含属性(Proper ...

  5. ThinkPHP 3.2.3的 R 方法

    R方法是可以调用其他的Controller中的方法, 例如 我想在Mit/DebugController.class.php中调用Foo/DoController.class.php中的share方法 ...

  6. List对象排序的通用方法

    转自 @author chenchuang import java.lang.reflect.InvocationTargetException;import java.lang.reflect.Me ...

  7. Docker Centos安装Openssh

    环境介绍: Docker版本:1.5.0 镜像:docker.io:centos latest 操作步骤: 1.启动镜像 docker run -ti centos /bin/bash 2.安装pas ...

  8. 23、jQuery九类选择器/jQuery常用Method-API/jQuery常用Event-API

      1)掌握jQuery九类选择器及应用 2)掌握jQuery常用Method-API 3)掌握jQuery常用Event-API 一)jQuery九类选择器[参见jQueryAPI.chm手册] 目 ...

  9. 用C#.NET编写软件注册机

    验证注册码是保护软件产品产权的常用手段.一般过程如下, 1.  软件发行者收集用户特有的信息: 2.  根据用户特有的信息,使用注册机生成注册码并把注册码发给客户: 3.  向软件导入注册码,由软件自 ...

  10. 完整学习git四git对象

    1查看git对象 git cat-file 实践 git head到底指向的是什么 ➜ gittest git:(master) find .git -name HEAD -o -name maste ...