//粘贴到帧上运行即可

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. GPS学习

    1.每一个你不满意的现在,都有一个你没有努力的曾经. //ios根据gps坐标来计算两点间的距离 //x1,y1 点1的坐标 x2,y2点2的坐标 -(double) gps2m:(double)x1 ...

  2. Spring注解@Scheduled定时任务

    一.首先配置applicationContext-task.xml (1)添加 xmlns:task="http://www.springframework.org/schema/task& ...

  3. Eclipse如何设置字体

    Eclipse 是一个开放源代码的.基于Java的可扩展开发平台,是学习java和开发java最常用的IDE之一.有时候会遇到这种情况,刚刚下载了新的Eclipse,字体显示英文没问题,但是显示中文就 ...

  4. BZOJ 1588:营业额统计(Splay)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1588 题意:中文题意. 思路:每一个点每一个点插入Splay,然后插入新的一个点之后,查这个节点的前 ...

  5. lua代码优化(转)

    暂时转了别人一篇,以后再优化 1.使用局部变量local 这是最基础也是最有用的策略,虽然使用全局变量并不能完全避免,但还是应该尽量避免,取而代之使用局部变量即local.这里的局部变量也包括函数fu ...

  6. hbase regionserver IO问题

    regionserver日志: java.io.IOException: Connection reset by peer         at sun.nio.ch.FileDispatcherIm ...

  7. android应用程序中获取view 的位置

    1. 相对位置: getLeft() , getRight(), getTop(), getBottom() 在Android中可以把left相当于X轴值, top相当于Y轴值, 通过这两个值Andr ...

  8. js笔记---封装一般运动

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. 20150820 PROCEDURE 模板

    USE [DB_H_F1]GO/****** Object:  StoredProcedure [dbo].[sp_sys_user_add]    Script Date: 08/19/2015 1 ...

  10. Let the Balloon Rise 分类: HDU 2015-06-19 19:11 7人阅读 评论(0) 收藏

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...